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