Code : Tout sélectionner
; #FUNCTION# ====================================================================================================================
; Name...........: _IsWirelessAdapter
; Description....: Checks if a network adapter is a wireless type
; Syntax.........: _IsWirelessAdapter($sAdapter)
; Parameters.....: $sNetAdapter - Name of the network adapter
; Return values..: Success - Returns 1
; Failure - 0
; ===============================================================================================================================
Func _IsWirelessAdapter($sAdapter)
Local $hDLL = DllOpen("wlanapi.dll"), $aResult, $hClientHandle, $pInterfaceList, _
$tInterfaceList, $iInterfaceCount, $tInterface, $pInterface, $tGUID, $pGUID
$aResult = DllCall($hDLL, "dword", "WlanOpenHandle", "dword", 2, "ptr", 0, "dword*", 0, "hwnd*", 0)
If @error Or $aResult[0] Then Return 0
$hClientHandle = $aResult[4]
$aResult = DllCall($hDLL, "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle, "ptr", 0, "ptr*", 0)
If @error Or $aResult[0] Then Return 0
$pInterfaceList = $aResult[3]
$tInterfaceList = DllStructCreate("dword", $pInterfaceList)
$iInterfaceCount = DllStructGetData($tInterfaceList, 1)
If Not $iInterfaceCount Then Return 0
Local $abGUIDs[$iInterfaceCount]
For $i = 0 To $iInterfaceCount - 1
$pInterface = Ptr(Number($pInterfaceList) + ($i * 532 + 8))
$tInterface = DllStructCreate("byte GUID[16]; wchar descr[256]; int State", $pInterface)
$abGUIDs[$i] = DllStructGetData($tInterface, "GUID")
If DllStructGetData($tInterface, "descr") == $sAdapter Then Return 1
Next
DllCall($hDLL, "dword", "WlanFreeMemory", "ptr", $pInterfaceList)
$tGUID = DllStructCreate("byte[16]")
DllStructSetData($tGUID, 1, $abGUIDs[0])
$pGUID = DllStructGetPtr($tGUID)
DllCall($hDLL, "dword", "WlanCloseHandle", "ptr", $hClientHandle, "ptr", 0)
DllClose($hDLL)
Return 0
EndFunc ; ===> _IsWirelessAdapter