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

WlanHostedNetworkSetSecondaryKey

関数
ホストネットワークのセカンダリセキュリティキーを設定する。
DLLwlanapi.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// 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
);

パラメーター

名前方向
hClientHandleHANDLEin
dwKeyLengthDWORDin
pucKeyDataBYTE*in
bIsPassPhraseBOOLin
bPersistentBOOLin
pFailReasonWLAN_HOSTED_NETWORK_REASON*outoptional
pvReservedvoid*optional

戻り値の型: 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, 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, int, 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 -> "int"
; pvReserved : void* optional -> "sptr"
; ※出力/バッファ引数は 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, var, int, int, int, 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 -> "int"
; pvReserved : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。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   // DWORD
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';
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)。