Hy Guy 我有一个问题,c# 调用本机函数 wlanenuminterfaces 函数返回 ok = (0) 但我不知道为什么......接口的 Guid 都是 {000000000000000000} 为什么?有人可以帮助我吗?非常感谢我发布代码...
[DllImport("wlanapi.dll")]
internal static extern int WlanEnumInterfaces([In]IntPtr HandleClient, [In,Out]IntPtr Reserved, [In,Out] WLAN_INTERFACE_INFO_LIST ine);`
[StructLayout(LayoutKind.Sequential)]
internal class WLAN_INTERFACE_INFO_LIST
{
internal int dwNumberOfItems;
internal int dwIndex;
internal WLAN_INTERFACE_INFO[] InterfaceInfo;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal class WLAN_INTERFACE_INFO
{
internal Guid interfaceGuid;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
internal string strInterfaceDescription;
internal WLAN_INTERFACE_STATE Istate;
}
internal enum WLAN_INTERFACE_STATE
{
wlan_interface_state_not_ready = 0,
wlan_interface_state_connected = 1,
wlan_interface_state_ad_hoc_network_formed = 2,
wlan_interface_state_disconnecting = 3,
wlan_interface_state_disconnected = 4,
wlan_interface_state_associating = 5,
wlan_interface_state_discovering = 6,
wlan_interface_state_authenticating = 7
}
info = new WLAN_INTERFACE_INFO_LIST();
list = new WLAN_INTERFACE_INFO();
IntPtr info1 = Marshal.AllocHGlobal(Marshal.SizeOf(info));
IntPtr list1 = Marshal.AllocHGlobal(Marshal.SizeOf(list));
int enuminterface = Win32Intereop.WlanEnumInterfaces(handle, IntPtr.Zero, info);
if (enuminterface != 0)
{
MessageBox.Show("Problema Enum Interface");
}
IntPtr num = (IntPtr)info.dwNumberOfItems;
info.dwNumberOfItems = Marshal.ReadInt32(num);
info.InterfaceInfo = new WLAN_INTERFACE_INFO[info.dwNumberOfItems];
for (int i = 0; i < info.dwNumberOfItems; i++)
{
info.InterfaceInfo[i] = list;
}