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