WLANAPI and OpCodes

  • Thread starter Thread starter Toby Webb
  • Start date Start date
T

Toby Webb

How can I convert the following code (from MSDN) to work in VB.NET
(the opcodes are raising errors):

Public Enum WLAN_INTF_OPCODE
wlan_intf_opcode_autoconf_start = 0x000000000
wlan_intf_opcode_autoconf_enabled = 0x0fffffff
wlan_intf_opcode_background_scan_enabled = 0x0fffffff
wlan_intf_opcode_media_streaming_mode = 0x0fffffff
wlan_intf_opcode_radio_state = 0x0fffffff
wlan_intf_opcode_bss_type = 0x0fffffff
wlan_intf_opcode_interface_state = 0x0fffffff
wlan_intf_opcode_current_connection = 0x0fffffff
wlan_intf_opcode_channel_number = 0x0fffffff
wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs =
0x0fffffff
wlan_intf_opcode_supported_adhoc_auth_cipher_pairs =
0x0fffffff
wlan_intf_opcode_supported_country_or_region_string_list =
0x0fffffff
wlan_intf_opcode_current_operation_mode = 0x0fffffff
wlan_intf_opcode_supported_safe_mode = 0x0fffffff
wlan_intf_opcode_certified_safe_mode = 0x0fffffff
wlan_intf_opcode_autoconf_end = 0x0fffffff
wlan_intf_opcode_msm_start = 0x10000100
wlan_intf_opcode_statistics = 0x1fffffff
wlan_intf_opcode_rssi = 0x1fffffff
wlan_intf_opcode_msm_end = 0x1fffffff
wlan_intf_opcode_security_start = 0x20010000
wlan_intf_opcode_security_end = 0x2fffffff
wlan_intf_opcode_ihv_start = 0x30000000
wlan_intf_opcode_ihv_end = 0x3fffffff
End Enum


Thanks in advance,

Toby.
 
Replace all "0x" with "&H" should do the trick, at least as far as I can
tell.









- Show quoted text -

Ah, thanks for that, works a charm.

I don't suppose anyone has the code for using WlanQueryInterface
(WLANAPI) in VB.NET??
 
Hi Tony,

Those values you have there are wrong I beleive. I would make the values as
:

Enum WLAN_INTF_OPCODE
autoconf_start = &H0
autoconf_enabled
background_scan_enabled
media_streaming_mode
radio_state
bss_type
interface_state
current_connection
channel_number
supported_infrastructure_auth_cipher_pairs
supported_adhoc_auth_cipher_pairs
supported_country_or_region_string_list
current_operation_mode
autoconf_end = &HFFFFFFF
msm_start = &H10000100
statistics
rssi
msm_end = &H1FFFFFFF
security_start = &H20010000
security_end = &H2FFFFFFF
ihv_start = &H30000000
ihv_end = &H3FFFFFFF
End Enum
 
Hi Tony,

Those values you have there are wrong I beleive.  I would make the values as
:

Enum WLAN_INTF_OPCODE
   autoconf_start = &H0
   autoconf_enabled
   background_scan_enabled
   media_streaming_mode
   radio_state
   bss_type
   interface_state
   current_connection
   channel_number
   supported_infrastructure_auth_cipher_pairs
   supported_adhoc_auth_cipher_pairs
   supported_country_or_region_string_list
   current_operation_mode
   autoconf_end = &HFFFFFFF
   msm_start = &H10000100
   statistics
   rssi
   msm_end = &H1FFFFFFF
   security_start = &H20010000
   security_end = &H2FFFFFFF
   ihv_start = &H30000000
   ihv_end = &H3FFFFFFF
End Enum









- Show quoted text -

Thanks Bill, do you know how the import code should read? I currently
have:

<DllImport("wlanapi", setlasterror:=True)>_
Public Shared Function WlanQueryInterface(_
ByVal clientHandle As IntPtr,_
ByVal pInterfaceGuid As Guid,_
ByVal OpCode As WLAN_INTF_OPCODE,_
ByVal pReserved As IntPtr,_
ByRef pdwDataSize As IntPtr,_
ByRef ppData As IntPtr)_
As UInteger
End Function
 
Toby Webb said:
Thanks Bill, do you know how the import code should read? I currently
have:


I make it as :


' DWORD WINAPI
' WlanQueryInterface(
' __in HANDLE hClientHandle,
' __in CONST GUID *pInterfaceGuid,
' __in WLAN_INTF_OPCODE OpCode,
' __reserved PVOID pReserved,
' __out PDWORD pdwDataSize,
' __deref_out_bcount(*pdwDataSize) PVOID *ppData,
' __out_opt PWLAN_OPCODE_VALUE_TYPE pWlanOpcodeValueType
');



Declare Function WlanQueryInterface Lib "wlanapi" ( _
ByVal clientHandle As IntPtr, _
ByRef pInterfaceGuid As Guid, _
ByVal OpCode As WLAN_INTF_OPCODE, _
ByVal pReserved As IntPtr, _
ByRef pdwDataSize As Int32, _
ByRef ppData As IntPtr, _
ByRef pWlanOpcodeValueType As Int32) _
As UInt32


Note the second parameter pInterfaceGuid I think needs to be a pointer to
the GUID, hence I changed it to ByRef, and you didn't have the last
parameter, pWlanOpcodeValueType
 
Back
Top