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