ホーム › NetworkManagement.WiFi › WlanGetProfileCustomUserData
WlanGetProfileCustomUserData
関数無線LANプロファイルのアプリ独自カスタムデータを取得する。
シグネチャ
// wlanapi.dll
#include <windows.h>
DWORD WlanGetProfileCustomUserData(
HANDLE hClientHandle,
const GUID* pInterfaceGuid,
LPCWSTR strProfileName,
void* pReserved, // optional
DWORD* pdwDataSize,
BYTE** ppData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hClientHandle | HANDLE | in | WlanOpenHandleで取得したクライアントセッションのハンドル。 |
| pInterfaceGuid | GUID* | in | 対象の無線LANインターフェースを識別するGUIDへのポインター。 |
| strProfileName | LPCWSTR | in | カスタムユーザーデータを取得する対象プロファイル名。 |
| pReserved | void* | optional | 予約領域。NULLを指定する必要がある。 |
| pdwDataSize | DWORD* | out | 取得したデータのバイト数を受け取る出力先。 |
| ppData | BYTE** | out | 取得したカスタムデータを受け取るポインター。WlanFreeMemoryで解放する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// wlanapi.dll
#include <windows.h>
DWORD WlanGetProfileCustomUserData(
HANDLE hClientHandle,
const GUID* pInterfaceGuid,
LPCWSTR strProfileName,
void* pReserved, // optional
DWORD* pdwDataSize,
BYTE** ppData
);[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanGetProfileCustomUserData(
IntPtr hClientHandle, // HANDLE
ref Guid pInterfaceGuid, // GUID*
[MarshalAs(UnmanagedType.LPWStr)] string strProfileName, // LPCWSTR
IntPtr pReserved, // void* optional
out uint pdwDataSize, // DWORD* out
IntPtr ppData // BYTE** out
);<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanGetProfileCustomUserData(
hClientHandle As IntPtr, ' HANDLE
ByRef pInterfaceGuid As Guid, ' GUID*
<MarshalAs(UnmanagedType.LPWStr)> strProfileName As String, ' LPCWSTR
pReserved As IntPtr, ' void* optional
<Out> ByRef pdwDataSize As UInteger, ' DWORD* out
ppData As IntPtr ' BYTE** out
) As UInteger
End Function' hClientHandle : HANDLE
' pInterfaceGuid : GUID*
' strProfileName : LPCWSTR
' pReserved : void* optional
' pdwDataSize : DWORD* out
' ppData : BYTE** out
Declare PtrSafe Function WlanGetProfileCustomUserData Lib "wlanapi" ( _
ByVal hClientHandle As LongPtr, _
ByVal pInterfaceGuid As LongPtr, _
ByVal strProfileName As LongPtr, _
ByVal pReserved As LongPtr, _
ByRef pdwDataSize As Long, _
ByVal ppData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WlanGetProfileCustomUserData = ctypes.windll.wlanapi.WlanGetProfileCustomUserData
WlanGetProfileCustomUserData.restype = wintypes.DWORD
WlanGetProfileCustomUserData.argtypes = [
wintypes.HANDLE, # hClientHandle : HANDLE
ctypes.c_void_p, # pInterfaceGuid : GUID*
wintypes.LPCWSTR, # strProfileName : LPCWSTR
ctypes.POINTER(None), # pReserved : void* optional
ctypes.POINTER(wintypes.DWORD), # pdwDataSize : DWORD* out
ctypes.c_void_p, # ppData : BYTE** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wlanapi.dll')
WlanGetProfileCustomUserData = Fiddle::Function.new(
lib['WlanGetProfileCustomUserData'],
[
Fiddle::TYPE_VOIDP, # hClientHandle : HANDLE
Fiddle::TYPE_VOIDP, # pInterfaceGuid : GUID*
Fiddle::TYPE_VOIDP, # strProfileName : LPCWSTR
Fiddle::TYPE_VOIDP, # pReserved : void* optional
Fiddle::TYPE_VOIDP, # pdwDataSize : DWORD* out
Fiddle::TYPE_VOIDP, # ppData : BYTE** out
],
-Fiddle::TYPE_INT)#[link(name = "wlanapi")]
extern "system" {
fn WlanGetProfileCustomUserData(
hClientHandle: *mut core::ffi::c_void, // HANDLE
pInterfaceGuid: *const GUID, // GUID*
strProfileName: *const u16, // LPCWSTR
pReserved: *mut (), // void* optional
pdwDataSize: *mut u32, // DWORD* out
ppData: *mut *mut u8 // BYTE** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanGetProfileCustomUserData(IntPtr hClientHandle, ref Guid pInterfaceGuid, [MarshalAs(UnmanagedType.LPWStr)] string strProfileName, IntPtr pReserved, out uint pdwDataSize, IntPtr ppData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanGetProfileCustomUserData' -Namespace Win32 -PassThru
# $api::WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData)#uselib "wlanapi.dll"
#func global WlanGetProfileCustomUserData "WlanGetProfileCustomUserData" sptr, sptr, sptr, sptr, sptr, sptr
; WlanGetProfileCustomUserData hClientHandle, varptr(pInterfaceGuid), strProfileName, pReserved, varptr(pdwDataSize), varptr(ppData) ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "sptr"
; strProfileName : LPCWSTR -> "sptr"
; pReserved : void* optional -> "sptr"
; pdwDataSize : DWORD* out -> "sptr"
; ppData : BYTE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "wlanapi.dll" #cfunc global WlanGetProfileCustomUserData "WlanGetProfileCustomUserData" sptr, var, wstr, sptr, var, var ; res = WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData) ; hClientHandle : HANDLE -> "sptr" ; pInterfaceGuid : GUID* -> "var" ; strProfileName : LPCWSTR -> "wstr" ; pReserved : void* optional -> "sptr" ; pdwDataSize : DWORD* out -> "var" ; ppData : BYTE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wlanapi.dll" #cfunc global WlanGetProfileCustomUserData "WlanGetProfileCustomUserData" sptr, sptr, wstr, sptr, sptr, sptr ; res = WlanGetProfileCustomUserData(hClientHandle, varptr(pInterfaceGuid), strProfileName, pReserved, varptr(pdwDataSize), varptr(ppData)) ; hClientHandle : HANDLE -> "sptr" ; pInterfaceGuid : GUID* -> "sptr" ; strProfileName : LPCWSTR -> "wstr" ; pReserved : void* optional -> "sptr" ; pdwDataSize : DWORD* out -> "sptr" ; ppData : BYTE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD WlanGetProfileCustomUserData(HANDLE hClientHandle, GUID* pInterfaceGuid, LPCWSTR strProfileName, void* pReserved, DWORD* pdwDataSize, BYTE** ppData) #uselib "wlanapi.dll" #cfunc global WlanGetProfileCustomUserData "WlanGetProfileCustomUserData" intptr, var, wstr, intptr, var, var ; res = WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData) ; hClientHandle : HANDLE -> "intptr" ; pInterfaceGuid : GUID* -> "var" ; strProfileName : LPCWSTR -> "wstr" ; pReserved : void* optional -> "intptr" ; pdwDataSize : DWORD* out -> "var" ; ppData : BYTE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WlanGetProfileCustomUserData(HANDLE hClientHandle, GUID* pInterfaceGuid, LPCWSTR strProfileName, void* pReserved, DWORD* pdwDataSize, BYTE** ppData) #uselib "wlanapi.dll" #cfunc global WlanGetProfileCustomUserData "WlanGetProfileCustomUserData" intptr, intptr, wstr, intptr, intptr, intptr ; res = WlanGetProfileCustomUserData(hClientHandle, varptr(pInterfaceGuid), strProfileName, pReserved, varptr(pdwDataSize), varptr(ppData)) ; hClientHandle : HANDLE -> "intptr" ; pInterfaceGuid : GUID* -> "intptr" ; strProfileName : LPCWSTR -> "wstr" ; pReserved : void* optional -> "intptr" ; pdwDataSize : DWORD* out -> "intptr" ; ppData : BYTE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
procWlanGetProfileCustomUserData = wlanapi.NewProc("WlanGetProfileCustomUserData")
)
// hClientHandle (HANDLE), pInterfaceGuid (GUID*), strProfileName (LPCWSTR), pReserved (void* optional), pdwDataSize (DWORD* out), ppData (BYTE** out)
r1, _, err := procWlanGetProfileCustomUserData.Call(
uintptr(hClientHandle),
uintptr(pInterfaceGuid),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strProfileName))),
uintptr(pReserved),
uintptr(pdwDataSize),
uintptr(ppData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WlanGetProfileCustomUserData(
hClientHandle: THandle; // HANDLE
pInterfaceGuid: PGUID; // GUID*
strProfileName: PWideChar; // LPCWSTR
pReserved: Pointer; // void* optional
pdwDataSize: Pointer; // DWORD* out
ppData: Pointer // BYTE** out
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanGetProfileCustomUserData';result := DllCall("wlanapi\WlanGetProfileCustomUserData"
, "Ptr", hClientHandle ; HANDLE
, "Ptr", pInterfaceGuid ; GUID*
, "WStr", strProfileName ; LPCWSTR
, "Ptr", pReserved ; void* optional
, "Ptr", pdwDataSize ; DWORD* out
, "Ptr", ppData ; BYTE** out
, "UInt") ; return: DWORD●WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData) = DLL("wlanapi.dll", "dword WlanGetProfileCustomUserData(void*, void*, char*, void*, void*, void*)")
# 呼び出し: WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData)
# hClientHandle : HANDLE -> "void*"
# pInterfaceGuid : GUID* -> "void*"
# strProfileName : LPCWSTR -> "char*"
# pReserved : void* optional -> "void*"
# pdwDataSize : DWORD* out -> "void*"
# ppData : BYTE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wlanapi" fn WlanGetProfileCustomUserData(
hClientHandle: ?*anyopaque, // HANDLE
pInterfaceGuid: [*c]GUID, // GUID*
strProfileName: [*c]const u16, // LPCWSTR
pReserved: ?*anyopaque, // void* optional
pdwDataSize: [*c]u32, // DWORD* out
ppData: [*c][*c]u8 // BYTE** out
) callconv(std.os.windows.WINAPI) u32;proc WlanGetProfileCustomUserData(
hClientHandle: pointer, # HANDLE
pInterfaceGuid: ptr GUID, # GUID*
strProfileName: WideCString, # LPCWSTR
pReserved: pointer, # void* optional
pdwDataSize: ptr uint32, # DWORD* out
ppData: ptr uint8 # BYTE** out
): uint32 {.importc: "WlanGetProfileCustomUserData", stdcall, dynlib: "wlanapi.dll".}pragma(lib, "wlanapi");
extern(Windows)
uint WlanGetProfileCustomUserData(
void* hClientHandle, // HANDLE
GUID* pInterfaceGuid, // GUID*
const(wchar)* strProfileName, // LPCWSTR
void* pReserved, // void* optional
uint* pdwDataSize, // DWORD* out
ubyte** ppData // BYTE** out
);ccall((:WlanGetProfileCustomUserData, "wlanapi.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{GUID}, Cwstring, Ptr{Cvoid}, Ptr{UInt32}, Ptr{UInt8}),
hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData)
# hClientHandle : HANDLE -> Ptr{Cvoid}
# pInterfaceGuid : GUID* -> Ptr{GUID}
# strProfileName : LPCWSTR -> Cwstring
# pReserved : void* optional -> Ptr{Cvoid}
# pdwDataSize : DWORD* out -> Ptr{UInt32}
# ppData : BYTE** out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WlanGetProfileCustomUserData(
void* hClientHandle,
void* pInterfaceGuid,
const uint16_t* strProfileName,
void* pReserved,
uint32_t* pdwDataSize,
uint8_t** ppData);
]]
local wlanapi = ffi.load("wlanapi")
-- wlanapi.WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData)
-- hClientHandle : HANDLE
-- pInterfaceGuid : GUID*
-- strProfileName : LPCWSTR
-- pReserved : void* optional
-- pdwDataSize : DWORD* out
-- ppData : BYTE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wlanapi.dll');
const WlanGetProfileCustomUserData = lib.func('__stdcall', 'WlanGetProfileCustomUserData', 'uint32_t', ['void *', 'void *', 'str16', 'void *', 'uint32_t *', 'uint8_t *']);
// WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData)
// hClientHandle : HANDLE -> 'void *'
// pInterfaceGuid : GUID* -> 'void *'
// strProfileName : LPCWSTR -> 'str16'
// pReserved : void* optional -> 'void *'
// pdwDataSize : DWORD* out -> 'uint32_t *'
// ppData : BYTE** out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wlanapi.dll", {
WlanGetProfileCustomUserData: { parameters: ["pointer", "pointer", "buffer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData)
// hClientHandle : HANDLE -> "pointer"
// pInterfaceGuid : GUID* -> "pointer"
// strProfileName : LPCWSTR -> "buffer"
// pReserved : void* optional -> "pointer"
// pdwDataSize : DWORD* out -> "pointer"
// ppData : BYTE** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WlanGetProfileCustomUserData(
void* hClientHandle,
void* pInterfaceGuid,
const uint16_t* strProfileName,
void* pReserved,
uint32_t* pdwDataSize,
uint8_t** ppData);
C, "wlanapi.dll");
// $ffi->WlanGetProfileCustomUserData(hClientHandle, pInterfaceGuid, strProfileName, pReserved, pdwDataSize, ppData);
// hClientHandle : HANDLE
// pInterfaceGuid : GUID*
// strProfileName : LPCWSTR
// pReserved : void* optional
// pdwDataSize : DWORD* out
// ppData : BYTE** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wlanapi extends StdCallLibrary {
Wlanapi INSTANCE = Native.load("wlanapi", Wlanapi.class);
int WlanGetProfileCustomUserData(
Pointer hClientHandle, // HANDLE
Pointer pInterfaceGuid, // GUID*
WString strProfileName, // LPCWSTR
Pointer pReserved, // void* optional
IntByReference pdwDataSize, // DWORD* out
Pointer ppData // BYTE** out
);
}@[Link("wlanapi")]
lib Libwlanapi
fun WlanGetProfileCustomUserData = WlanGetProfileCustomUserData(
hClientHandle : Void*, # HANDLE
pInterfaceGuid : GUID*, # GUID*
strProfileName : UInt16*, # LPCWSTR
pReserved : Void*, # void* optional
pdwDataSize : UInt32*, # DWORD* out
ppData : UInt8** # BYTE** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WlanGetProfileCustomUserDataNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint8>);
typedef WlanGetProfileCustomUserDataDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint8>);
final WlanGetProfileCustomUserData = DynamicLibrary.open('wlanapi.dll')
.lookupFunction<WlanGetProfileCustomUserDataNative, WlanGetProfileCustomUserDataDart>('WlanGetProfileCustomUserData');
// hClientHandle : HANDLE -> Pointer<Void>
// pInterfaceGuid : GUID* -> Pointer<Void>
// strProfileName : LPCWSTR -> Pointer<Utf16>
// pReserved : void* optional -> Pointer<Void>
// pdwDataSize : DWORD* out -> Pointer<Uint32>
// ppData : BYTE** out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WlanGetProfileCustomUserData(
hClientHandle: THandle; // HANDLE
pInterfaceGuid: PGUID; // GUID*
strProfileName: PWideChar; // LPCWSTR
pReserved: Pointer; // void* optional
pdwDataSize: Pointer; // DWORD* out
ppData: Pointer // BYTE** out
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanGetProfileCustomUserData';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WlanGetProfileCustomUserData"
c_WlanGetProfileCustomUserData :: Ptr () -> Ptr () -> CWString -> Ptr () -> Ptr Word32 -> Ptr Word8 -> IO Word32
-- hClientHandle : HANDLE -> Ptr ()
-- pInterfaceGuid : GUID* -> Ptr ()
-- strProfileName : LPCWSTR -> CWString
-- pReserved : void* optional -> Ptr ()
-- pdwDataSize : DWORD* out -> Ptr Word32
-- ppData : BYTE** out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wlangetprofilecustomuserdata =
foreign "WlanGetProfileCustomUserData"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr uint8_t) @-> returning uint32_t)
(* hClientHandle : HANDLE -> (ptr void) *)
(* pInterfaceGuid : GUID* -> (ptr void) *)
(* strProfileName : LPCWSTR -> (ptr uint16_t) *)
(* pReserved : void* optional -> (ptr void) *)
(* pdwDataSize : DWORD* out -> (ptr uint32_t) *)
(* ppData : BYTE** out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wlanapi (t "wlanapi.dll"))
(cffi:use-foreign-library wlanapi)
(cffi:defcfun ("WlanGetProfileCustomUserData" wlan-get-profile-custom-user-data :convention :stdcall) :uint32
(h-client-handle :pointer) ; HANDLE
(p-interface-guid :pointer) ; GUID*
(str-profile-name (:string :encoding :utf-16le)) ; LPCWSTR
(p-reserved :pointer) ; void* optional
(pdw-data-size :pointer) ; DWORD* out
(pp-data :pointer)) ; BYTE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WlanGetProfileCustomUserData = Win32::API::More->new('wlanapi',
'DWORD WlanGetProfileCustomUserData(HANDLE hClientHandle, LPVOID pInterfaceGuid, LPCWSTR strProfileName, LPVOID pReserved, LPVOID pdwDataSize, LPVOID ppData)');
# my $ret = $WlanGetProfileCustomUserData->Call($hClientHandle, $pInterfaceGuid, $strProfileName, $pReserved, $pdwDataSize, $ppData);
# hClientHandle : HANDLE -> HANDLE
# pInterfaceGuid : GUID* -> LPVOID
# strProfileName : LPCWSTR -> LPCWSTR
# pReserved : void* optional -> LPVOID
# pdwDataSize : DWORD* out -> LPVOID
# ppData : BYTE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。