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

WlanSetProfileCustomUserData

関数
無線LANプロファイルにアプリ独自のカスタムデータを設定する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD WlanSetProfileCustomUserData(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    LPCWSTR strProfileName,
    DWORD dwDataSize,
    const BYTE* pData,
    void* pReserved   // optional
);

パラメーター

名前方向
hClientHandleHANDLEin
pInterfaceGuidGUID*in
strProfileNameLPCWSTRin
dwDataSizeDWORDin
pDataBYTE*in
pReservedvoid*optional

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // DWORD
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';
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)。