33 lines
1022 B
C#
33 lines
1022 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UPNPLib;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace UpnpEnumSupport
|
|
{
|
|
public class UpnpSupport
|
|
{
|
|
public static string[] FindDeviceByType(string URI)
|
|
{
|
|
IUPnPDeviceFinder DeviceFinder = new UPnPDeviceFinder();
|
|
IUPnPDevices Devices = DeviceFinder.FindByType(URI, 0);
|
|
if (Devices != null && Devices.Count > 0)
|
|
{
|
|
List<string> UDNList = new List<string>();
|
|
foreach (IUPnPDevice Device in Devices)
|
|
{
|
|
UDNList.Add(Device.UniqueDeviceName);
|
|
Marshal.FinalReleaseComObject(Device);
|
|
}
|
|
Marshal.FinalReleaseComObject(Devices);
|
|
Marshal.FinalReleaseComObject(DeviceFinder);
|
|
return UDNList.ToArray();
|
|
}
|
|
Marshal.FinalReleaseComObject(DeviceFinder);
|
|
return null;
|
|
}
|
|
}
|
|
}
|