ホーム › NetworkManagement.WiFi › WlanHostedNetworkSetSecondaryKey
WlanHostedNetworkSetSecondaryKey
関数ホストネットワークのセカンダリセキュリティキーを設定する。
シグネチャ
// wlanapi.dll
#include <windows.h>
DWORD WlanHostedNetworkSetSecondaryKey(
HANDLE hClientHandle,
DWORD dwKeyLength,
BYTE* pucKeyData,
BOOL bIsPassPhrase,
BOOL bPersistent,
WLAN_HOSTED_NETWORK_REASON* pFailReason, // optional
void* pvReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hClientHandle | HANDLE | in | WlanOpenHandleで取得したクライアントセッションのハンドル。 |
| dwKeyLength | DWORD | in | pucKeyDataが指すキーデータのバイト数。 |
| pucKeyData | BYTE* | in | 設定するセカンダリキー(パスフレーズまたはバイナリ)へのポインター。 |
| bIsPassPhrase | BOOL | in | TRUEならキーデータをパスフレーズ文字列として扱う。 |
| bPersistent | BOOL | in | TRUEならキーを永続化し、FALSEなら一時的に使用する。 |
| pFailReason | WLAN_HOSTED_NETWORK_REASON* | outoptional | 失敗時に原因を示すWLAN_HOSTED_NETWORK_REASONを受け取る出力先。 |
| pvReserved | void* | optional | 予約領域。NULLを指定する必要がある。 |
戻り値の型: DWORD
各言語での呼び出し定義
// wlanapi.dll
#include <windows.h>
DWORD WlanHostedNetworkSetSecondaryKey(
HANDLE hClientHandle,
DWORD dwKeyLength,
BYTE* pucKeyData,
BOOL bIsPassPhrase,
BOOL bPersistent,
WLAN_HOSTED_NETWORK_REASON* pFailReason, // optional
void* pvReserved // optional
);[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanHostedNetworkSetSecondaryKey(
IntPtr hClientHandle, // HANDLE
uint dwKeyLength, // DWORD
IntPtr pucKeyData, // BYTE*
bool bIsPassPhrase, // BOOL
bool bPersistent, // BOOL
IntPtr pFailReason, // WLAN_HOSTED_NETWORK_REASON* optional, out
IntPtr pvReserved // void* optional
);<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanHostedNetworkSetSecondaryKey(
hClientHandle As IntPtr, ' HANDLE
dwKeyLength As UInteger, ' DWORD
pucKeyData As IntPtr, ' BYTE*
bIsPassPhrase As Boolean, ' BOOL
bPersistent As Boolean, ' BOOL
pFailReason As IntPtr, ' WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved As IntPtr ' void* optional
) As UInteger
End Function' hClientHandle : HANDLE
' dwKeyLength : DWORD
' pucKeyData : BYTE*
' bIsPassPhrase : BOOL
' bPersistent : BOOL
' pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out
' pvReserved : void* optional
Declare PtrSafe Function WlanHostedNetworkSetSecondaryKey Lib "wlanapi" ( _
ByVal hClientHandle As LongPtr, _
ByVal dwKeyLength As Long, _
ByVal pucKeyData As LongPtr, _
ByVal bIsPassPhrase As Long, _
ByVal bPersistent As Long, _
ByVal pFailReason As LongPtr, _
ByVal pvReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WlanHostedNetworkSetSecondaryKey = ctypes.windll.wlanapi.WlanHostedNetworkSetSecondaryKey
WlanHostedNetworkSetSecondaryKey.restype = wintypes.DWORD
WlanHostedNetworkSetSecondaryKey.argtypes = [
wintypes.HANDLE, # hClientHandle : HANDLE
wintypes.DWORD, # dwKeyLength : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pucKeyData : BYTE*
wintypes.BOOL, # bIsPassPhrase : BOOL
wintypes.BOOL, # bPersistent : BOOL
ctypes.c_void_p, # pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out
ctypes.POINTER(None), # pvReserved : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wlanapi.dll')
WlanHostedNetworkSetSecondaryKey = Fiddle::Function.new(
lib['WlanHostedNetworkSetSecondaryKey'],
[
Fiddle::TYPE_VOIDP, # hClientHandle : HANDLE
-Fiddle::TYPE_INT, # dwKeyLength : DWORD
Fiddle::TYPE_VOIDP, # pucKeyData : BYTE*
Fiddle::TYPE_INT, # bIsPassPhrase : BOOL
Fiddle::TYPE_INT, # bPersistent : BOOL
Fiddle::TYPE_VOIDP, # pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out
Fiddle::TYPE_VOIDP, # pvReserved : void* optional
],
-Fiddle::TYPE_INT)#[link(name = "wlanapi")]
extern "system" {
fn WlanHostedNetworkSetSecondaryKey(
hClientHandle: *mut core::ffi::c_void, // HANDLE
dwKeyLength: u32, // DWORD
pucKeyData: *mut u8, // BYTE*
bIsPassPhrase: i32, // BOOL
bPersistent: i32, // BOOL
pFailReason: *mut i32, // WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved: *mut () // void* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanHostedNetworkSetSecondaryKey(IntPtr hClientHandle, uint dwKeyLength, IntPtr pucKeyData, bool bIsPassPhrase, bool bPersistent, IntPtr pFailReason, IntPtr pvReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanHostedNetworkSetSecondaryKey' -Namespace Win32 -PassThru
# $api::WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved)#uselib "wlanapi.dll"
#func global WlanHostedNetworkSetSecondaryKey "WlanHostedNetworkSetSecondaryKey" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WlanHostedNetworkSetSecondaryKey hClientHandle, dwKeyLength, varptr(pucKeyData), bIsPassPhrase, bPersistent, varptr(pFailReason), pvReserved ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; dwKeyLength : DWORD -> "sptr"
; pucKeyData : BYTE* -> "sptr"
; bIsPassPhrase : BOOL -> "sptr"
; bPersistent : BOOL -> "sptr"
; pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "sptr"
; pvReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "wlanapi.dll" #cfunc global WlanHostedNetworkSetSecondaryKey "WlanHostedNetworkSetSecondaryKey" sptr, int, var, int, int, var, sptr ; res = WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved) ; hClientHandle : HANDLE -> "sptr" ; dwKeyLength : DWORD -> "int" ; pucKeyData : BYTE* -> "var" ; bIsPassPhrase : BOOL -> "int" ; bPersistent : BOOL -> "int" ; pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "var" ; pvReserved : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wlanapi.dll" #cfunc global WlanHostedNetworkSetSecondaryKey "WlanHostedNetworkSetSecondaryKey" sptr, int, sptr, int, int, sptr, sptr ; res = WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, varptr(pucKeyData), bIsPassPhrase, bPersistent, varptr(pFailReason), pvReserved) ; hClientHandle : HANDLE -> "sptr" ; dwKeyLength : DWORD -> "int" ; pucKeyData : BYTE* -> "sptr" ; bIsPassPhrase : BOOL -> "int" ; bPersistent : BOOL -> "int" ; pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "sptr" ; pvReserved : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD WlanHostedNetworkSetSecondaryKey(HANDLE hClientHandle, DWORD dwKeyLength, BYTE* pucKeyData, BOOL bIsPassPhrase, BOOL bPersistent, WLAN_HOSTED_NETWORK_REASON* pFailReason, void* pvReserved) #uselib "wlanapi.dll" #cfunc global WlanHostedNetworkSetSecondaryKey "WlanHostedNetworkSetSecondaryKey" intptr, int, var, int, int, var, intptr ; res = WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved) ; hClientHandle : HANDLE -> "intptr" ; dwKeyLength : DWORD -> "int" ; pucKeyData : BYTE* -> "var" ; bIsPassPhrase : BOOL -> "int" ; bPersistent : BOOL -> "int" ; pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "var" ; pvReserved : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WlanHostedNetworkSetSecondaryKey(HANDLE hClientHandle, DWORD dwKeyLength, BYTE* pucKeyData, BOOL bIsPassPhrase, BOOL bPersistent, WLAN_HOSTED_NETWORK_REASON* pFailReason, void* pvReserved) #uselib "wlanapi.dll" #cfunc global WlanHostedNetworkSetSecondaryKey "WlanHostedNetworkSetSecondaryKey" intptr, int, intptr, int, int, intptr, intptr ; res = WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, varptr(pucKeyData), bIsPassPhrase, bPersistent, varptr(pFailReason), pvReserved) ; hClientHandle : HANDLE -> "intptr" ; dwKeyLength : DWORD -> "int" ; pucKeyData : BYTE* -> "intptr" ; bIsPassPhrase : BOOL -> "int" ; bPersistent : BOOL -> "int" ; pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "intptr" ; pvReserved : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
procWlanHostedNetworkSetSecondaryKey = wlanapi.NewProc("WlanHostedNetworkSetSecondaryKey")
)
// hClientHandle (HANDLE), dwKeyLength (DWORD), pucKeyData (BYTE*), bIsPassPhrase (BOOL), bPersistent (BOOL), pFailReason (WLAN_HOSTED_NETWORK_REASON* optional, out), pvReserved (void* optional)
r1, _, err := procWlanHostedNetworkSetSecondaryKey.Call(
uintptr(hClientHandle),
uintptr(dwKeyLength),
uintptr(pucKeyData),
uintptr(bIsPassPhrase),
uintptr(bPersistent),
uintptr(pFailReason),
uintptr(pvReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WlanHostedNetworkSetSecondaryKey(
hClientHandle: THandle; // HANDLE
dwKeyLength: DWORD; // DWORD
pucKeyData: Pointer; // BYTE*
bIsPassPhrase: BOOL; // BOOL
bPersistent: BOOL; // BOOL
pFailReason: Pointer; // WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved: Pointer // void* optional
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanHostedNetworkSetSecondaryKey';result := DllCall("wlanapi\WlanHostedNetworkSetSecondaryKey"
, "Ptr", hClientHandle ; HANDLE
, "UInt", dwKeyLength ; DWORD
, "Ptr", pucKeyData ; BYTE*
, "Int", bIsPassPhrase ; BOOL
, "Int", bPersistent ; BOOL
, "Ptr", pFailReason ; WLAN_HOSTED_NETWORK_REASON* optional, out
, "Ptr", pvReserved ; void* optional
, "UInt") ; return: DWORD●WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved) = DLL("wlanapi.dll", "dword WlanHostedNetworkSetSecondaryKey(void*, dword, void*, bool, bool, void*, void*)")
# 呼び出し: WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved)
# hClientHandle : HANDLE -> "void*"
# dwKeyLength : DWORD -> "dword"
# pucKeyData : BYTE* -> "void*"
# bIsPassPhrase : BOOL -> "bool"
# bPersistent : BOOL -> "bool"
# pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "void*"
# pvReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wlanapi" fn WlanHostedNetworkSetSecondaryKey(
hClientHandle: ?*anyopaque, // HANDLE
dwKeyLength: u32, // DWORD
pucKeyData: [*c]u8, // BYTE*
bIsPassPhrase: i32, // BOOL
bPersistent: i32, // BOOL
pFailReason: [*c]i32, // WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;proc WlanHostedNetworkSetSecondaryKey(
hClientHandle: pointer, # HANDLE
dwKeyLength: uint32, # DWORD
pucKeyData: ptr uint8, # BYTE*
bIsPassPhrase: int32, # BOOL
bPersistent: int32, # BOOL
pFailReason: ptr int32, # WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved: pointer # void* optional
): uint32 {.importc: "WlanHostedNetworkSetSecondaryKey", stdcall, dynlib: "wlanapi.dll".}pragma(lib, "wlanapi");
extern(Windows)
uint WlanHostedNetworkSetSecondaryKey(
void* hClientHandle, // HANDLE
uint dwKeyLength, // DWORD
ubyte* pucKeyData, // BYTE*
int bIsPassPhrase, // BOOL
int bPersistent, // BOOL
int* pFailReason, // WLAN_HOSTED_NETWORK_REASON* optional, out
void* pvReserved // void* optional
);ccall((:WlanHostedNetworkSetSecondaryKey, "wlanapi.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{UInt8}, Int32, Int32, Ptr{Int32}, Ptr{Cvoid}),
hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved)
# hClientHandle : HANDLE -> Ptr{Cvoid}
# dwKeyLength : DWORD -> UInt32
# pucKeyData : BYTE* -> Ptr{UInt8}
# bIsPassPhrase : BOOL -> Int32
# bPersistent : BOOL -> Int32
# pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> Ptr{Int32}
# pvReserved : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WlanHostedNetworkSetSecondaryKey(
void* hClientHandle,
uint32_t dwKeyLength,
uint8_t* pucKeyData,
int32_t bIsPassPhrase,
int32_t bPersistent,
int32_t* pFailReason,
void* pvReserved);
]]
local wlanapi = ffi.load("wlanapi")
-- wlanapi.WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved)
-- hClientHandle : HANDLE
-- dwKeyLength : DWORD
-- pucKeyData : BYTE*
-- bIsPassPhrase : BOOL
-- bPersistent : BOOL
-- pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out
-- pvReserved : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wlanapi.dll');
const WlanHostedNetworkSetSecondaryKey = lib.func('__stdcall', 'WlanHostedNetworkSetSecondaryKey', 'uint32_t', ['void *', 'uint32_t', 'uint8_t *', 'int32_t', 'int32_t', 'int32_t *', 'void *']);
// WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved)
// hClientHandle : HANDLE -> 'void *'
// dwKeyLength : DWORD -> 'uint32_t'
// pucKeyData : BYTE* -> 'uint8_t *'
// bIsPassPhrase : BOOL -> 'int32_t'
// bPersistent : BOOL -> 'int32_t'
// pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> 'int32_t *'
// pvReserved : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wlanapi.dll", {
WlanHostedNetworkSetSecondaryKey: { parameters: ["pointer", "u32", "pointer", "i32", "i32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved)
// hClientHandle : HANDLE -> "pointer"
// dwKeyLength : DWORD -> "u32"
// pucKeyData : BYTE* -> "pointer"
// bIsPassPhrase : BOOL -> "i32"
// bPersistent : BOOL -> "i32"
// pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> "pointer"
// pvReserved : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WlanHostedNetworkSetSecondaryKey(
void* hClientHandle,
uint32_t dwKeyLength,
uint8_t* pucKeyData,
int32_t bIsPassPhrase,
int32_t bPersistent,
int32_t* pFailReason,
void* pvReserved);
C, "wlanapi.dll");
// $ffi->WlanHostedNetworkSetSecondaryKey(hClientHandle, dwKeyLength, pucKeyData, bIsPassPhrase, bPersistent, pFailReason, pvReserved);
// hClientHandle : HANDLE
// dwKeyLength : DWORD
// pucKeyData : BYTE*
// bIsPassPhrase : BOOL
// bPersistent : BOOL
// pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out
// pvReserved : 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 WlanHostedNetworkSetSecondaryKey(
Pointer hClientHandle, // HANDLE
int dwKeyLength, // DWORD
byte[] pucKeyData, // BYTE*
boolean bIsPassPhrase, // BOOL
boolean bPersistent, // BOOL
IntByReference pFailReason, // WLAN_HOSTED_NETWORK_REASON* optional, out
Pointer pvReserved // void* optional
);
}@[Link("wlanapi")]
lib Libwlanapi
fun WlanHostedNetworkSetSecondaryKey = WlanHostedNetworkSetSecondaryKey(
hClientHandle : Void*, # HANDLE
dwKeyLength : UInt32, # DWORD
pucKeyData : UInt8*, # BYTE*
bIsPassPhrase : Int32, # BOOL
bPersistent : Int32, # BOOL
pFailReason : Int32*, # WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved : 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 WlanHostedNetworkSetSecondaryKeyNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Uint8>, Int32, Int32, Pointer<Int32>, Pointer<Void>);
typedef WlanHostedNetworkSetSecondaryKeyDart = int Function(Pointer<Void>, int, Pointer<Uint8>, int, int, Pointer<Int32>, Pointer<Void>);
final WlanHostedNetworkSetSecondaryKey = DynamicLibrary.open('wlanapi.dll')
.lookupFunction<WlanHostedNetworkSetSecondaryKeyNative, WlanHostedNetworkSetSecondaryKeyDart>('WlanHostedNetworkSetSecondaryKey');
// hClientHandle : HANDLE -> Pointer<Void>
// dwKeyLength : DWORD -> Uint32
// pucKeyData : BYTE* -> Pointer<Uint8>
// bIsPassPhrase : BOOL -> Int32
// bPersistent : BOOL -> Int32
// pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> Pointer<Int32>
// pvReserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WlanHostedNetworkSetSecondaryKey(
hClientHandle: THandle; // HANDLE
dwKeyLength: DWORD; // DWORD
pucKeyData: Pointer; // BYTE*
bIsPassPhrase: BOOL; // BOOL
bPersistent: BOOL; // BOOL
pFailReason: Pointer; // WLAN_HOSTED_NETWORK_REASON* optional, out
pvReserved: Pointer // void* optional
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanHostedNetworkSetSecondaryKey';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WlanHostedNetworkSetSecondaryKey"
c_WlanHostedNetworkSetSecondaryKey :: Ptr () -> Word32 -> Ptr Word8 -> CInt -> CInt -> Ptr Int32 -> Ptr () -> IO Word32
-- hClientHandle : HANDLE -> Ptr ()
-- dwKeyLength : DWORD -> Word32
-- pucKeyData : BYTE* -> Ptr Word8
-- bIsPassPhrase : BOOL -> CInt
-- bPersistent : BOOL -> CInt
-- pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> Ptr Int32
-- pvReserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wlanhostednetworksetsecondarykey =
foreign "WlanHostedNetworkSetSecondaryKey"
((ptr void) @-> uint32_t @-> (ptr uint8_t) @-> int32_t @-> int32_t @-> (ptr int32_t) @-> (ptr void) @-> returning uint32_t)
(* hClientHandle : HANDLE -> (ptr void) *)
(* dwKeyLength : DWORD -> uint32_t *)
(* pucKeyData : BYTE* -> (ptr uint8_t) *)
(* bIsPassPhrase : BOOL -> int32_t *)
(* bPersistent : BOOL -> int32_t *)
(* pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> (ptr int32_t) *)
(* pvReserved : 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 ("WlanHostedNetworkSetSecondaryKey" wlan-hosted-network-set-secondary-key :convention :stdcall) :uint32
(h-client-handle :pointer) ; HANDLE
(dw-key-length :uint32) ; DWORD
(puc-key-data :pointer) ; BYTE*
(b-is-pass-phrase :int32) ; BOOL
(b-persistent :int32) ; BOOL
(p-fail-reason :pointer) ; WLAN_HOSTED_NETWORK_REASON* optional, out
(pv-reserved :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WlanHostedNetworkSetSecondaryKey = Win32::API::More->new('wlanapi',
'DWORD WlanHostedNetworkSetSecondaryKey(HANDLE hClientHandle, DWORD dwKeyLength, LPVOID pucKeyData, BOOL bIsPassPhrase, BOOL bPersistent, LPVOID pFailReason, LPVOID pvReserved)');
# my $ret = $WlanHostedNetworkSetSecondaryKey->Call($hClientHandle, $dwKeyLength, $pucKeyData, $bIsPassPhrase, $bPersistent, $pFailReason, $pvReserved);
# hClientHandle : HANDLE -> HANDLE
# dwKeyLength : DWORD -> DWORD
# pucKeyData : BYTE* -> LPVOID
# bIsPassPhrase : BOOL -> BOOL
# bPersistent : BOOL -> BOOL
# pFailReason : WLAN_HOSTED_NETWORK_REASON* optional, out -> LPVOID
# pvReserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。