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

WlanGetProfile

関数
指定した無線LANプロファイルのXML内容を取得する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

パラメーター

名前方向
hClientHandleHANDLEin
pInterfaceGuidGUID*in
strProfileNameLPCWSTRin
pReservedvoid*optional
pstrProfileXmlLPWSTR*out
pdwFlagsDWORD*inoutoptional
pdwGrantedAccessDWORD*outoptional

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // DWORD
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';
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)。