Files
Labview-Program/Boyi Airleak (LV2015 64bits)/UpnpEnumSupport/UpnpEnumSupport/UpnpSupport.cs
chanweehewsonos b433b3592a initial
2025-09-10 12:58:29 +08:00

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;
}
}
}