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

WlanSetProfile

関数
無線LANプロファイルをXMLから追加または更新する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD WlanSetProfile(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    DWORD dwFlags,
    LPCWSTR strProfileXml,
    LPCWSTR strAllUserProfileSecurity,   // optional
    BOOL bOverwrite,
    void* pReserved,   // optional
    DWORD* pdwReasonCode
);

パラメーター

名前方向説明
hClientHandleHANDLEinWlanOpenHandleで取得したクライアントセッションのハンドル。
pInterfaceGuidGUID*in対象の無線LANインターフェースを識別するGUIDへのポインター。
dwFlagsDWORDinプロファイル種別フラグ。WLAN_PROFILE_USER等を指定する。0で全ユーザー。
strProfileXmlLPCWSTRin設定するプロファイルの内容をXML形式で記述した文字列。
strAllUserProfileSecurityLPCWSTRinoptional全ユーザープロファイルのアクセス制御を記述したSDDL文字列。NULL可。
bOverwriteBOOLinTRUEなら同名プロファイルを上書きし、FALSEなら既存時に失敗する。
pReservedvoid*optional予約領域。NULLを指定する必要がある。
pdwReasonCodeDWORD*outプロファイルが無効な場合の理由コードを受け取る出力先。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WlanSetProfile(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    DWORD dwFlags,
    LPCWSTR strProfileXml,
    LPCWSTR strAllUserProfileSecurity,   // optional
    BOOL bOverwrite,
    void* pReserved,   // optional
    DWORD* pdwReasonCode
);
[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanSetProfile(
    IntPtr hClientHandle,   // HANDLE
    ref Guid pInterfaceGuid,   // GUID*
    uint dwFlags,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string strProfileXml,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string strAllUserProfileSecurity,   // LPCWSTR optional
    bool bOverwrite,   // BOOL
    IntPtr pReserved,   // void* optional
    out uint pdwReasonCode   // DWORD* out
);
<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanSetProfile(
    hClientHandle As IntPtr,   ' HANDLE
    ByRef pInterfaceGuid As Guid,   ' GUID*
    dwFlags As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> strProfileXml As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> strAllUserProfileSecurity As String,   ' LPCWSTR optional
    bOverwrite As Boolean,   ' BOOL
    pReserved As IntPtr,   ' void* optional
    <Out> ByRef pdwReasonCode As UInteger   ' DWORD* out
) As UInteger
End Function
' hClientHandle : HANDLE
' pInterfaceGuid : GUID*
' dwFlags : DWORD
' strProfileXml : LPCWSTR
' strAllUserProfileSecurity : LPCWSTR optional
' bOverwrite : BOOL
' pReserved : void* optional
' pdwReasonCode : DWORD* out
Declare PtrSafe Function WlanSetProfile Lib "wlanapi" ( _
    ByVal hClientHandle As LongPtr, _
    ByVal pInterfaceGuid As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal strProfileXml As LongPtr, _
    ByVal strAllUserProfileSecurity As LongPtr, _
    ByVal bOverwrite As Long, _
    ByVal pReserved As LongPtr, _
    ByRef pdwReasonCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WlanSetProfile = ctypes.windll.wlanapi.WlanSetProfile
WlanSetProfile.restype = wintypes.DWORD
WlanSetProfile.argtypes = [
    wintypes.HANDLE,  # hClientHandle : HANDLE
    ctypes.c_void_p,  # pInterfaceGuid : GUID*
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.LPCWSTR,  # strProfileXml : LPCWSTR
    wintypes.LPCWSTR,  # strAllUserProfileSecurity : LPCWSTR optional
    wintypes.BOOL,  # bOverwrite : BOOL
    ctypes.POINTER(None),  # pReserved : void* optional
    ctypes.POINTER(wintypes.DWORD),  # pdwReasonCode : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
	procWlanSetProfile = wlanapi.NewProc("WlanSetProfile")
)

// hClientHandle (HANDLE), pInterfaceGuid (GUID*), dwFlags (DWORD), strProfileXml (LPCWSTR), strAllUserProfileSecurity (LPCWSTR optional), bOverwrite (BOOL), pReserved (void* optional), pdwReasonCode (DWORD* out)
r1, _, err := procWlanSetProfile.Call(
	uintptr(hClientHandle),
	uintptr(pInterfaceGuid),
	uintptr(dwFlags),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strProfileXml))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strAllUserProfileSecurity))),
	uintptr(bOverwrite),
	uintptr(pReserved),
	uintptr(pdwReasonCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WlanSetProfile(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  dwFlags: DWORD;   // DWORD
  strProfileXml: PWideChar;   // LPCWSTR
  strAllUserProfileSecurity: PWideChar;   // LPCWSTR optional
  bOverwrite: BOOL;   // BOOL
  pReserved: Pointer;   // void* optional
  pdwReasonCode: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanSetProfile';
result := DllCall("wlanapi\WlanSetProfile"
    , "Ptr", hClientHandle   ; HANDLE
    , "Ptr", pInterfaceGuid   ; GUID*
    , "UInt", dwFlags   ; DWORD
    , "WStr", strProfileXml   ; LPCWSTR
    , "WStr", strAllUserProfileSecurity   ; LPCWSTR optional
    , "Int", bOverwrite   ; BOOL
    , "Ptr", pReserved   ; void* optional
    , "Ptr", pdwReasonCode   ; DWORD* out
    , "UInt")   ; return: DWORD
●WlanSetProfile(hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode) = DLL("wlanapi.dll", "dword WlanSetProfile(void*, void*, dword, char*, char*, bool, void*, void*)")
# 呼び出し: WlanSetProfile(hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode)
# hClientHandle : HANDLE -> "void*"
# pInterfaceGuid : GUID* -> "void*"
# dwFlags : DWORD -> "dword"
# strProfileXml : LPCWSTR -> "char*"
# strAllUserProfileSecurity : LPCWSTR optional -> "char*"
# bOverwrite : BOOL -> "bool"
# pReserved : void* optional -> "void*"
# pdwReasonCode : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wlanapi" fn WlanSetProfile(
    hClientHandle: ?*anyopaque, // HANDLE
    pInterfaceGuid: [*c]GUID, // GUID*
    dwFlags: u32, // DWORD
    strProfileXml: [*c]const u16, // LPCWSTR
    strAllUserProfileSecurity: [*c]const u16, // LPCWSTR optional
    bOverwrite: i32, // BOOL
    pReserved: ?*anyopaque, // void* optional
    pdwReasonCode: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) u32;
proc WlanSetProfile(
    hClientHandle: pointer,  # HANDLE
    pInterfaceGuid: ptr GUID,  # GUID*
    dwFlags: uint32,  # DWORD
    strProfileXml: WideCString,  # LPCWSTR
    strAllUserProfileSecurity: WideCString,  # LPCWSTR optional
    bOverwrite: int32,  # BOOL
    pReserved: pointer,  # void* optional
    pdwReasonCode: ptr uint32  # DWORD* out
): uint32 {.importc: "WlanSetProfile", stdcall, dynlib: "wlanapi.dll".}
pragma(lib, "wlanapi");
extern(Windows)
uint WlanSetProfile(
    void* hClientHandle,   // HANDLE
    GUID* pInterfaceGuid,   // GUID*
    uint dwFlags,   // DWORD
    const(wchar)* strProfileXml,   // LPCWSTR
    const(wchar)* strAllUserProfileSecurity,   // LPCWSTR optional
    int bOverwrite,   // BOOL
    void* pReserved,   // void* optional
    uint* pdwReasonCode   // DWORD* out
);
ccall((:WlanSetProfile, "wlanapi.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Ptr{GUID}, UInt32, Cwstring, Cwstring, Int32, Ptr{Cvoid}, Ptr{UInt32}),
      hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode)
# hClientHandle : HANDLE -> Ptr{Cvoid}
# pInterfaceGuid : GUID* -> Ptr{GUID}
# dwFlags : DWORD -> UInt32
# strProfileXml : LPCWSTR -> Cwstring
# strAllUserProfileSecurity : LPCWSTR optional -> Cwstring
# bOverwrite : BOOL -> Int32
# pReserved : void* optional -> Ptr{Cvoid}
# pdwReasonCode : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WlanSetProfile(
    void* hClientHandle,
    void* pInterfaceGuid,
    uint32_t dwFlags,
    const uint16_t* strProfileXml,
    const uint16_t* strAllUserProfileSecurity,
    int32_t bOverwrite,
    void* pReserved,
    uint32_t* pdwReasonCode);
]]
local wlanapi = ffi.load("wlanapi")
-- wlanapi.WlanSetProfile(hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode)
-- hClientHandle : HANDLE
-- pInterfaceGuid : GUID*
-- dwFlags : DWORD
-- strProfileXml : LPCWSTR
-- strAllUserProfileSecurity : LPCWSTR optional
-- bOverwrite : BOOL
-- pReserved : void* optional
-- pdwReasonCode : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wlanapi.dll');
const WlanSetProfile = lib.func('__stdcall', 'WlanSetProfile', 'uint32_t', ['void *', 'void *', 'uint32_t', 'str16', 'str16', 'int32_t', 'void *', 'uint32_t *']);
// WlanSetProfile(hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode)
// hClientHandle : HANDLE -> 'void *'
// pInterfaceGuid : GUID* -> 'void *'
// dwFlags : DWORD -> 'uint32_t'
// strProfileXml : LPCWSTR -> 'str16'
// strAllUserProfileSecurity : LPCWSTR optional -> 'str16'
// bOverwrite : BOOL -> 'int32_t'
// pReserved : void* optional -> 'void *'
// pdwReasonCode : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wlanapi.dll", {
  WlanSetProfile: { parameters: ["pointer", "pointer", "u32", "buffer", "buffer", "i32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.WlanSetProfile(hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode)
// hClientHandle : HANDLE -> "pointer"
// pInterfaceGuid : GUID* -> "pointer"
// dwFlags : DWORD -> "u32"
// strProfileXml : LPCWSTR -> "buffer"
// strAllUserProfileSecurity : LPCWSTR optional -> "buffer"
// bOverwrite : BOOL -> "i32"
// pReserved : void* optional -> "pointer"
// pdwReasonCode : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WlanSetProfile(
    void* hClientHandle,
    void* pInterfaceGuid,
    uint32_t dwFlags,
    const uint16_t* strProfileXml,
    const uint16_t* strAllUserProfileSecurity,
    int32_t bOverwrite,
    void* pReserved,
    uint32_t* pdwReasonCode);
C, "wlanapi.dll");
// $ffi->WlanSetProfile(hClientHandle, pInterfaceGuid, dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, pdwReasonCode);
// hClientHandle : HANDLE
// pInterfaceGuid : GUID*
// dwFlags : DWORD
// strProfileXml : LPCWSTR
// strAllUserProfileSecurity : LPCWSTR optional
// bOverwrite : BOOL
// pReserved : void* optional
// pdwReasonCode : DWORD* 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 WlanSetProfile(
        Pointer hClientHandle,   // HANDLE
        Pointer pInterfaceGuid,   // GUID*
        int dwFlags,   // DWORD
        WString strProfileXml,   // LPCWSTR
        WString strAllUserProfileSecurity,   // LPCWSTR optional
        boolean bOverwrite,   // BOOL
        Pointer pReserved,   // void* optional
        IntByReference pdwReasonCode   // DWORD* out
    );
}
@[Link("wlanapi")]
lib Libwlanapi
  fun WlanSetProfile = WlanSetProfile(
    hClientHandle : Void*,   # HANDLE
    pInterfaceGuid : GUID*,   # GUID*
    dwFlags : UInt32,   # DWORD
    strProfileXml : UInt16*,   # LPCWSTR
    strAllUserProfileSecurity : UInt16*,   # LPCWSTR optional
    bOverwrite : Int32,   # BOOL
    pReserved : Void*,   # void* optional
    pdwReasonCode : UInt32*   # DWORD* out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WlanSetProfileNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Utf16>, Int32, Pointer<Void>, Pointer<Uint32>);
typedef WlanSetProfileDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Void>, Pointer<Uint32>);
final WlanSetProfile = DynamicLibrary.open('wlanapi.dll')
    .lookupFunction<WlanSetProfileNative, WlanSetProfileDart>('WlanSetProfile');
// hClientHandle : HANDLE -> Pointer<Void>
// pInterfaceGuid : GUID* -> Pointer<Void>
// dwFlags : DWORD -> Uint32
// strProfileXml : LPCWSTR -> Pointer<Utf16>
// strAllUserProfileSecurity : LPCWSTR optional -> Pointer<Utf16>
// bOverwrite : BOOL -> Int32
// pReserved : void* optional -> Pointer<Void>
// pdwReasonCode : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WlanSetProfile(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  dwFlags: DWORD;   // DWORD
  strProfileXml: PWideChar;   // LPCWSTR
  strAllUserProfileSecurity: PWideChar;   // LPCWSTR optional
  bOverwrite: BOOL;   // BOOL
  pReserved: Pointer;   // void* optional
  pdwReasonCode: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanSetProfile';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WlanSetProfile"
  c_WlanSetProfile :: Ptr () -> Ptr () -> Word32 -> CWString -> CWString -> CInt -> Ptr () -> Ptr Word32 -> IO Word32
-- hClientHandle : HANDLE -> Ptr ()
-- pInterfaceGuid : GUID* -> Ptr ()
-- dwFlags : DWORD -> Word32
-- strProfileXml : LPCWSTR -> CWString
-- strAllUserProfileSecurity : LPCWSTR optional -> CWString
-- bOverwrite : BOOL -> CInt
-- pReserved : void* optional -> Ptr ()
-- pdwReasonCode : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wlansetprofile =
  foreign "WlanSetProfile"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr void) @-> (ptr uint32_t) @-> returning uint32_t)
(* hClientHandle : HANDLE -> (ptr void) *)
(* pInterfaceGuid : GUID* -> (ptr void) *)
(* dwFlags : DWORD -> uint32_t *)
(* strProfileXml : LPCWSTR -> (ptr uint16_t) *)
(* strAllUserProfileSecurity : LPCWSTR optional -> (ptr uint16_t) *)
(* bOverwrite : BOOL -> int32_t *)
(* pReserved : void* optional -> (ptr void) *)
(* pdwReasonCode : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wlanapi (t "wlanapi.dll"))
(cffi:use-foreign-library wlanapi)

(cffi:defcfun ("WlanSetProfile" wlan-set-profile :convention :stdcall) :uint32
  (h-client-handle :pointer)   ; HANDLE
  (p-interface-guid :pointer)   ; GUID*
  (dw-flags :uint32)   ; DWORD
  (str-profile-xml (:string :encoding :utf-16le))   ; LPCWSTR
  (str-all-user-profile-security (:string :encoding :utf-16le))   ; LPCWSTR optional
  (b-overwrite :int32)   ; BOOL
  (p-reserved :pointer)   ; void* optional
  (pdw-reason-code :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WlanSetProfile = Win32::API::More->new('wlanapi',
    'DWORD WlanSetProfile(HANDLE hClientHandle, LPVOID pInterfaceGuid, DWORD dwFlags, LPCWSTR strProfileXml, LPCWSTR strAllUserProfileSecurity, BOOL bOverwrite, LPVOID pReserved, LPVOID pdwReasonCode)');
# my $ret = $WlanSetProfile->Call($hClientHandle, $pInterfaceGuid, $dwFlags, $strProfileXml, $strAllUserProfileSecurity, $bOverwrite, $pReserved, $pdwReasonCode);
# hClientHandle : HANDLE -> HANDLE
# pInterfaceGuid : GUID* -> LPVOID
# dwFlags : DWORD -> DWORD
# strProfileXml : LPCWSTR -> LPCWSTR
# strAllUserProfileSecurity : LPCWSTR optional -> LPCWSTR
# bOverwrite : BOOL -> BOOL
# pReserved : void* optional -> LPVOID
# pdwReasonCode : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。