ホーム › NetworkManagement.WiFi › WlanScan
WlanScan
関数無線LANインターフェイスで利用可能なネットワークを走査する。
シグネチャ
// wlanapi.dll
#include <windows.h>
DWORD WlanScan(
HANDLE hClientHandle,
const GUID* pInterfaceGuid,
const DOT11_SSID* pDot11Ssid, // optional
const WLAN_RAW_DATA* pIeData, // optional
void* pReserved // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hClientHandle | HANDLE | in |
| pInterfaceGuid | GUID* | in |
| pDot11Ssid | DOT11_SSID* | inoptional |
| pIeData | WLAN_RAW_DATA* | inoptional |
| pReserved | void* | optional |
戻り値の型: DWORD
各言語での呼び出し定義
// wlanapi.dll
#include <windows.h>
DWORD WlanScan(
HANDLE hClientHandle,
const GUID* pInterfaceGuid,
const DOT11_SSID* pDot11Ssid, // optional
const WLAN_RAW_DATA* pIeData, // optional
void* pReserved // optional
);[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanScan(
IntPtr hClientHandle, // HANDLE
ref Guid pInterfaceGuid, // GUID*
IntPtr pDot11Ssid, // DOT11_SSID* optional
IntPtr pIeData, // WLAN_RAW_DATA* optional
IntPtr pReserved // void* optional
);<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanScan(
hClientHandle As IntPtr, ' HANDLE
ByRef pInterfaceGuid As Guid, ' GUID*
pDot11Ssid As IntPtr, ' DOT11_SSID* optional
pIeData As IntPtr, ' WLAN_RAW_DATA* optional
pReserved As IntPtr ' void* optional
) As UInteger
End Function' hClientHandle : HANDLE
' pInterfaceGuid : GUID*
' pDot11Ssid : DOT11_SSID* optional
' pIeData : WLAN_RAW_DATA* optional
' pReserved : void* optional
Declare PtrSafe Function WlanScan Lib "wlanapi" ( _
ByVal hClientHandle As LongPtr, _
ByVal pInterfaceGuid As LongPtr, _
ByVal pDot11Ssid As LongPtr, _
ByVal pIeData As LongPtr, _
ByVal pReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WlanScan = ctypes.windll.wlanapi.WlanScan
WlanScan.restype = wintypes.DWORD
WlanScan.argtypes = [
wintypes.HANDLE, # hClientHandle : HANDLE
ctypes.c_void_p, # pInterfaceGuid : GUID*
ctypes.c_void_p, # pDot11Ssid : DOT11_SSID* optional
ctypes.c_void_p, # pIeData : WLAN_RAW_DATA* optional
ctypes.POINTER(None), # pReserved : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wlanapi.dll')
WlanScan = Fiddle::Function.new(
lib['WlanScan'],
[
Fiddle::TYPE_VOIDP, # hClientHandle : HANDLE
Fiddle::TYPE_VOIDP, # pInterfaceGuid : GUID*
Fiddle::TYPE_VOIDP, # pDot11Ssid : DOT11_SSID* optional
Fiddle::TYPE_VOIDP, # pIeData : WLAN_RAW_DATA* optional
Fiddle::TYPE_VOIDP, # pReserved : void* optional
],
-Fiddle::TYPE_INT)#[link(name = "wlanapi")]
extern "system" {
fn WlanScan(
hClientHandle: *mut core::ffi::c_void, // HANDLE
pInterfaceGuid: *const GUID, // GUID*
pDot11Ssid: *const DOT11_SSID, // DOT11_SSID* optional
pIeData: *const WLAN_RAW_DATA, // WLAN_RAW_DATA* optional
pReserved: *mut () // void* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanScan(IntPtr hClientHandle, ref Guid pInterfaceGuid, IntPtr pDot11Ssid, IntPtr pIeData, IntPtr pReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanScan' -Namespace Win32 -PassThru
# $api::WlanScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData, pReserved)#uselib "wlanapi.dll"
#func global WlanScan "WlanScan" sptr, sptr, sptr, sptr, sptr
; WlanScan hClientHandle, varptr(pInterfaceGuid), varptr(pDot11Ssid), varptr(pIeData), pReserved ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "sptr"
; pDot11Ssid : DOT11_SSID* optional -> "sptr"
; pIeData : WLAN_RAW_DATA* optional -> "sptr"
; pReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "wlanapi.dll" #cfunc global WlanScan "WlanScan" sptr, var, var, var, sptr ; res = WlanScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData, pReserved) ; hClientHandle : HANDLE -> "sptr" ; pInterfaceGuid : GUID* -> "var" ; pDot11Ssid : DOT11_SSID* optional -> "var" ; pIeData : WLAN_RAW_DATA* optional -> "var" ; pReserved : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wlanapi.dll" #cfunc global WlanScan "WlanScan" sptr, sptr, sptr, sptr, sptr ; res = WlanScan(hClientHandle, varptr(pInterfaceGuid), varptr(pDot11Ssid), varptr(pIeData), pReserved) ; hClientHandle : HANDLE -> "sptr" ; pInterfaceGuid : GUID* -> "sptr" ; pDot11Ssid : DOT11_SSID* optional -> "sptr" ; pIeData : WLAN_RAW_DATA* optional -> "sptr" ; pReserved : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD WlanScan(HANDLE hClientHandle, GUID* pInterfaceGuid, DOT11_SSID* pDot11Ssid, WLAN_RAW_DATA* pIeData, void* pReserved) #uselib "wlanapi.dll" #cfunc global WlanScan "WlanScan" intptr, var, var, var, intptr ; res = WlanScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData, pReserved) ; hClientHandle : HANDLE -> "intptr" ; pInterfaceGuid : GUID* -> "var" ; pDot11Ssid : DOT11_SSID* optional -> "var" ; pIeData : WLAN_RAW_DATA* optional -> "var" ; pReserved : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WlanScan(HANDLE hClientHandle, GUID* pInterfaceGuid, DOT11_SSID* pDot11Ssid, WLAN_RAW_DATA* pIeData, void* pReserved) #uselib "wlanapi.dll" #cfunc global WlanScan "WlanScan" intptr, intptr, intptr, intptr, intptr ; res = WlanScan(hClientHandle, varptr(pInterfaceGuid), varptr(pDot11Ssid), varptr(pIeData), pReserved) ; hClientHandle : HANDLE -> "intptr" ; pInterfaceGuid : GUID* -> "intptr" ; pDot11Ssid : DOT11_SSID* optional -> "intptr" ; pIeData : WLAN_RAW_DATA* optional -> "intptr" ; pReserved : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
procWlanScan = wlanapi.NewProc("WlanScan")
)
// hClientHandle (HANDLE), pInterfaceGuid (GUID*), pDot11Ssid (DOT11_SSID* optional), pIeData (WLAN_RAW_DATA* optional), pReserved (void* optional)
r1, _, err := procWlanScan.Call(
uintptr(hClientHandle),
uintptr(pInterfaceGuid),
uintptr(pDot11Ssid),
uintptr(pIeData),
uintptr(pReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WlanScan(
hClientHandle: THandle; // HANDLE
pInterfaceGuid: PGUID; // GUID*
pDot11Ssid: Pointer; // DOT11_SSID* optional
pIeData: Pointer; // WLAN_RAW_DATA* optional
pReserved: Pointer // void* optional
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanScan';result := DllCall("wlanapi\WlanScan"
, "Ptr", hClientHandle ; HANDLE
, "Ptr", pInterfaceGuid ; GUID*
, "Ptr", pDot11Ssid ; DOT11_SSID* optional
, "Ptr", pIeData ; WLAN_RAW_DATA* optional
, "Ptr", pReserved ; void* optional
, "UInt") ; return: DWORD●WlanScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData, pReserved) = DLL("wlanapi.dll", "dword WlanScan(void*, void*, void*, void*, void*)")
# 呼び出し: WlanScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData, pReserved)
# hClientHandle : HANDLE -> "void*"
# pInterfaceGuid : GUID* -> "void*"
# pDot11Ssid : DOT11_SSID* optional -> "void*"
# pIeData : WLAN_RAW_DATA* optional -> "void*"
# pReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。