mirror of
https://github.com/netchx/netch.git
synced 2026-03-30 19:09:48 +08:00
20 lines
517 B
C#
20 lines
517 B
C#
using System.Management;
|
|
|
|
namespace Netch.Utils
|
|
{
|
|
static internal class WMI
|
|
{
|
|
public static ManagementObject GetManagementObjectByDeviceNameOrDefault(string deviceName)
|
|
{
|
|
foreach (ManagementObject mo in new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances())
|
|
{
|
|
if (((string) mo["Caption"]).EndsWith(deviceName))
|
|
{
|
|
return mo;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |