ホーム › NetworkManagement.WiFi › WlanSetProfile
WlanSetProfile
関数無線LANプロファイルをXMLから追加または更新する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hClientHandle | HANDLE | in |
| pInterfaceGuid | GUID* | in |
| dwFlags | DWORD | in |
| strProfileXml | LPCWSTR | in |
| strAllUserProfileSecurity | LPCWSTR | inoptional |
| bOverwrite | BOOL | in |
| pReserved | void* | optional |
| pdwReasonCode | DWORD* | 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 方式にも切替可。#uselib "wlanapi.dll" #cfunc global WlanSetProfile "WlanSetProfile" sptr, sptr, int, wstr, wstr, int, sptr, sptr ; res = WlanSetProfile(hClientHandle, varptr(pInterfaceGuid), dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, varptr(pdwReasonCode)) ; hClientHandle : HANDLE -> "sptr" ; pInterfaceGuid : GUID* -> "sptr" ; dwFlags : DWORD -> "int" ; strProfileXml : LPCWSTR -> "wstr" ; strAllUserProfileSecurity : LPCWSTR optional -> "wstr" ; bOverwrite : BOOL -> "int" ; pReserved : void* optional -> "sptr" ; pdwReasonCode : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, wstr, wstr, int, intptr, intptr ; res = WlanSetProfile(hClientHandle, varptr(pInterfaceGuid), dwFlags, strProfileXml, strAllUserProfileSecurity, bOverwrite, pReserved, varptr(pdwReasonCode)) ; hClientHandle : HANDLE -> "intptr" ; pInterfaceGuid : GUID* -> "intptr" ; dwFlags : DWORD -> "int" ; strProfileXml : LPCWSTR -> "wstr" ; strAllUserProfileSecurity : LPCWSTR optional -> "wstr" ; bOverwrite : BOOL -> "int" ; pReserved : void* optional -> "intptr" ; pdwReasonCode : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。