VB.NET运用WLANAPI,获取参数失败
Private Declare Function WlanOpenHandle Lib "wlanapi.dll" (ByVal dwClientVersion As UInteger, ByVal pReserved As IntPtr, <Out()> ByRef pdwNegotiatedVersion As UInteger, ByRef phClientHandle As IntPtr) As UInteger
Private Declare Function WlanCloseHandle Lib "wlanapi.dll" (<[In]()> ByVal hClientHandle As IntPtr, ByVal pReserved As IntPtr) As UInteger
Private Declare Function WlanEnumInterfaces Lib "wlanapi.dll" (<[In]()> ByVal hClientHandle As IntPtr, ByVal pReserved As IntPtr, <Out()> ByRef ppInterfaceList As IntPtr) As UInteger
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dwCurVersion As UInteger
Dim hClient As UInteger
Me.Text = WlanOpenHandle(2, Nothing, dwCurVersion, hClient)
Dim pi As IntPtr
Dim dwresult = WlanEnumInterfaces(hClient, Nothing, pi)
Dim rt As WLAN_INTERFACE_INFO_LIST
rt = Marshal.PtrToStructure(pi, GetType(WLAN_INTERFACE_INFO_LIST))
Label1.Text = rt.dwNumberofItems
End Sub
系统显示尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
这是为什么呢?这个程序目的是获取本地WIFI参数