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