Win32 API 日本語リファレンス
ホームNetworkManagement.WiFi › WlanRegisterNotification

WlanRegisterNotification

関数
WLANイベントの通知を受け取るコールバックを登録する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// wlanapi.dll
#include <windows.h>

DWORD WlanRegisterNotification(
    HANDLE hClientHandle,
    WLAN_NOTIFICATION_SOURCES dwNotifSource,
    BOOL bIgnoreDuplicate,
    WLAN_NOTIFICATION_CALLBACK funcCallback,   // optional
    void* pCallbackContext,   // optional
    void* pReserved,   // optional
    DWORD* pdwPrevNotifSource   // optional
);

パラメーター

名前方向
hClientHandleHANDLEin
dwNotifSourceWLAN_NOTIFICATION_SOURCESin
bIgnoreDuplicateBOOLin
funcCallbackWLAN_NOTIFICATION_CALLBACKinoptional
pCallbackContextvoid*inoptional
pReservedvoid*optional
pdwPrevNotifSourceDWORD*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

// wlanapi.dll
#include <windows.h>

DWORD WlanRegisterNotification(
    HANDLE hClientHandle,
    WLAN_NOTIFICATION_SOURCES dwNotifSource,
    BOOL bIgnoreDuplicate,
    WLAN_NOTIFICATION_CALLBACK funcCallback,   // optional
    void* pCallbackContext,   // optional
    void* pReserved,   // optional
    DWORD* pdwPrevNotifSource   // optional
);
[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanRegisterNotification(
    IntPtr hClientHandle,   // HANDLE
    uint dwNotifSource,   // WLAN_NOTIFICATION_SOURCES
    bool bIgnoreDuplicate,   // BOOL
    IntPtr funcCallback,   // WLAN_NOTIFICATION_CALLBACK optional
    IntPtr pCallbackContext,   // void* optional
    IntPtr pReserved,   // void* optional
    IntPtr pdwPrevNotifSource   // DWORD* optional, out
);
<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanRegisterNotification(
    hClientHandle As IntPtr,   ' HANDLE
    dwNotifSource As UInteger,   ' WLAN_NOTIFICATION_SOURCES
    bIgnoreDuplicate As Boolean,   ' BOOL
    funcCallback As IntPtr,   ' WLAN_NOTIFICATION_CALLBACK optional
    pCallbackContext As IntPtr,   ' void* optional
    pReserved As IntPtr,   ' void* optional
    pdwPrevNotifSource As IntPtr   ' DWORD* optional, out
) As UInteger
End Function
' hClientHandle : HANDLE
' dwNotifSource : WLAN_NOTIFICATION_SOURCES
' bIgnoreDuplicate : BOOL
' funcCallback : WLAN_NOTIFICATION_CALLBACK optional
' pCallbackContext : void* optional
' pReserved : void* optional
' pdwPrevNotifSource : DWORD* optional, out
Declare PtrSafe Function WlanRegisterNotification Lib "wlanapi" ( _
    ByVal hClientHandle As LongPtr, _
    ByVal dwNotifSource As Long, _
    ByVal bIgnoreDuplicate As Long, _
    ByVal funcCallback As LongPtr, _
    ByVal pCallbackContext As LongPtr, _
    ByVal pReserved As LongPtr, _
    ByVal pdwPrevNotifSource As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WlanRegisterNotification = ctypes.windll.wlanapi.WlanRegisterNotification
WlanRegisterNotification.restype = wintypes.DWORD
WlanRegisterNotification.argtypes = [
    wintypes.HANDLE,  # hClientHandle : HANDLE
    wintypes.DWORD,  # dwNotifSource : WLAN_NOTIFICATION_SOURCES
    wintypes.BOOL,  # bIgnoreDuplicate : BOOL
    ctypes.c_void_p,  # funcCallback : WLAN_NOTIFICATION_CALLBACK optional
    ctypes.POINTER(None),  # pCallbackContext : void* optional
    ctypes.POINTER(None),  # pReserved : void* optional
    ctypes.POINTER(wintypes.DWORD),  # pdwPrevNotifSource : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wlanapi.dll')
WlanRegisterNotification = Fiddle::Function.new(
  lib['WlanRegisterNotification'],
  [
    Fiddle::TYPE_VOIDP,  # hClientHandle : HANDLE
    -Fiddle::TYPE_INT,  # dwNotifSource : WLAN_NOTIFICATION_SOURCES
    Fiddle::TYPE_INT,  # bIgnoreDuplicate : BOOL
    Fiddle::TYPE_VOIDP,  # funcCallback : WLAN_NOTIFICATION_CALLBACK optional
    Fiddle::TYPE_VOIDP,  # pCallbackContext : void* optional
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional
    Fiddle::TYPE_VOIDP,  # pdwPrevNotifSource : DWORD* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wlanapi")]
extern "system" {
    fn WlanRegisterNotification(
        hClientHandle: *mut core::ffi::c_void,  // HANDLE
        dwNotifSource: u32,  // WLAN_NOTIFICATION_SOURCES
        bIgnoreDuplicate: i32,  // BOOL
        funcCallback: *const core::ffi::c_void,  // WLAN_NOTIFICATION_CALLBACK optional
        pCallbackContext: *mut (),  // void* optional
        pReserved: *mut (),  // void* optional
        pdwPrevNotifSource: *mut u32  // DWORD* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanRegisterNotification(IntPtr hClientHandle, uint dwNotifSource, bool bIgnoreDuplicate, IntPtr funcCallback, IntPtr pCallbackContext, IntPtr pReserved, IntPtr pdwPrevNotifSource);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanRegisterNotification' -Namespace Win32 -PassThru
# $api::WlanRegisterNotification(hClientHandle, dwNotifSource, bIgnoreDuplicate, funcCallback, pCallbackContext, pReserved, pdwPrevNotifSource)
#uselib "wlanapi.dll"
#func global WlanRegisterNotification "WlanRegisterNotification" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WlanRegisterNotification hClientHandle, dwNotifSource, bIgnoreDuplicate, funcCallback, pCallbackContext, pReserved, varptr(pdwPrevNotifSource)   ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; dwNotifSource : WLAN_NOTIFICATION_SOURCES -> "sptr"
; bIgnoreDuplicate : BOOL -> "sptr"
; funcCallback : WLAN_NOTIFICATION_CALLBACK optional -> "sptr"
; pCallbackContext : void* optional -> "sptr"
; pReserved : void* optional -> "sptr"
; pdwPrevNotifSource : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wlanapi.dll"
#cfunc global WlanRegisterNotification "WlanRegisterNotification" sptr, int, int, sptr, sptr, sptr, var
; res = WlanRegisterNotification(hClientHandle, dwNotifSource, bIgnoreDuplicate, funcCallback, pCallbackContext, pReserved, pdwPrevNotifSource)
; hClientHandle : HANDLE -> "sptr"
; dwNotifSource : WLAN_NOTIFICATION_SOURCES -> "int"
; bIgnoreDuplicate : BOOL -> "int"
; funcCallback : WLAN_NOTIFICATION_CALLBACK optional -> "sptr"
; pCallbackContext : void* optional -> "sptr"
; pReserved : void* optional -> "sptr"
; pdwPrevNotifSource : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WlanRegisterNotification(HANDLE hClientHandle, WLAN_NOTIFICATION_SOURCES dwNotifSource, BOOL bIgnoreDuplicate, WLAN_NOTIFICATION_CALLBACK funcCallback, void* pCallbackContext, void* pReserved, DWORD* pdwPrevNotifSource)
#uselib "wlanapi.dll"
#cfunc global WlanRegisterNotification "WlanRegisterNotification" intptr, int, int, intptr, intptr, intptr, var
; res = WlanRegisterNotification(hClientHandle, dwNotifSource, bIgnoreDuplicate, funcCallback, pCallbackContext, pReserved, pdwPrevNotifSource)
; hClientHandle : HANDLE -> "intptr"
; dwNotifSource : WLAN_NOTIFICATION_SOURCES -> "int"
; bIgnoreDuplicate : BOOL -> "int"
; funcCallback : WLAN_NOTIFICATION_CALLBACK optional -> "intptr"
; pCallbackContext : void* optional -> "intptr"
; pReserved : void* optional -> "intptr"
; pdwPrevNotifSource : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
	procWlanRegisterNotification = wlanapi.NewProc("WlanRegisterNotification")
)

// hClientHandle (HANDLE), dwNotifSource (WLAN_NOTIFICATION_SOURCES), bIgnoreDuplicate (BOOL), funcCallback (WLAN_NOTIFICATION_CALLBACK optional), pCallbackContext (void* optional), pReserved (void* optional), pdwPrevNotifSource (DWORD* optional, out)
r1, _, err := procWlanRegisterNotification.Call(
	uintptr(hClientHandle),
	uintptr(dwNotifSource),
	uintptr(bIgnoreDuplicate),
	uintptr(funcCallback),
	uintptr(pCallbackContext),
	uintptr(pReserved),
	uintptr(pdwPrevNotifSource),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WlanRegisterNotification(
  hClientHandle: THandle;   // HANDLE
  dwNotifSource: DWORD;   // WLAN_NOTIFICATION_SOURCES
  bIgnoreDuplicate: BOOL;   // BOOL
  funcCallback: Pointer;   // WLAN_NOTIFICATION_CALLBACK optional
  pCallbackContext: Pointer;   // void* optional
  pReserved: Pointer;   // void* optional
  pdwPrevNotifSource: Pointer   // DWORD* optional, out
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanRegisterNotification';
result := DllCall("wlanapi\WlanRegisterNotification"
    , "Ptr", hClientHandle   ; HANDLE
    , "UInt", dwNotifSource   ; WLAN_NOTIFICATION_SOURCES
    , "Int", bIgnoreDuplicate   ; BOOL
    , "Ptr", funcCallback   ; WLAN_NOTIFICATION_CALLBACK optional
    , "Ptr", pCallbackContext   ; void* optional
    , "Ptr", pReserved   ; void* optional
    , "Ptr", pdwPrevNotifSource   ; DWORD* optional, out
    , "UInt")   ; return: DWORD
●WlanRegisterNotification(hClientHandle, dwNotifSource, bIgnoreDuplicate, funcCallback, pCallbackContext, pReserved, pdwPrevNotifSource) = DLL("wlanapi.dll", "dword WlanRegisterNotification(void*, dword, bool, void*, void*, void*, void*)")
# 呼び出し: WlanRegisterNotification(hClientHandle, dwNotifSource, bIgnoreDuplicate, funcCallback, pCallbackContext, pReserved, pdwPrevNotifSource)
# hClientHandle : HANDLE -> "void*"
# dwNotifSource : WLAN_NOTIFICATION_SOURCES -> "dword"
# bIgnoreDuplicate : BOOL -> "bool"
# funcCallback : WLAN_NOTIFICATION_CALLBACK optional -> "void*"
# pCallbackContext : void* optional -> "void*"
# pReserved : void* optional -> "void*"
# pdwPrevNotifSource : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。