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

WlanGetProfileList

関数
インターフェイスに設定された無線LANプロファイル一覧を取得する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// wlanapi.dll
#include <windows.h>

DWORD WlanGetProfileList(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    void* pReserved,   // optional
    WLAN_PROFILE_INFO_LIST** ppProfileList
);

パラメーター

名前型方向説明
hClientHandleHANDLEinクライアントのセッションハンドル。事前に WlanOpenHandle 関数を呼び出して取得します。
pInterfaceGuidGUID*in

ワイヤレスインターフェイスの GUID。

ローカルコンピューター上のワイヤレスインターフェイスの GUID の一覧は、WlanEnumInterfaces 関数を使用して取得できます。

pReservedvoid*optional将来の使用のために予約されています。 NULL を設定する必要があります。
ppProfileListWLAN_PROFILE_INFO_LIST**outプロファイル情報の一覧を格納する PWLAN_PROFILE_INFO_LIST 構造体。

戻り値の型: DWORD

公式ドキュメント

プロファイルの一覧を取得します。

戻り値

関数が成功した場合、戻り値は ERROR_SUCCESS です。

関数が失敗した場合、戻り値は次のいずれかのリターンコードになることがあります。

リターンコード 説明
ERROR_INVALID_HANDLE
ハンドル hClientHandle がハンドルテーブル内に見つかりませんでした。
ERROR_INVALID_PARAMETER
パラメーターが正しくありません。このエラーは、次のいずれかの条件に該当する場合に返されます。
  • hClientHandle が NULL である。
  • pInterfaceGuid が NULL である。
  • ppProfileList が NULL である。
  • pReserved が NULL ではない。
ERROR_NOT_ENOUGH_MEMORY
この要求を処理し、クエリ結果用のメモリを割り当てるための十分なメモリがありません。
RPC_STATUS
さまざまなエラーコード。

解説(Remarks)

WlanGetProfileList 関数は、ワイヤレスインターフェイス上のワイヤレスプロファイルに関する基本的な情報のみを返します。ワイヤレスインターフェイス上のワイヤレスプロファイルの一覧は、優先順位の順で取得されます。WlanSetProfilePosition を使用すると、ワイヤレスインターフェイス上のワイヤレスプロファイルの優先順位を変更できます。

ワイヤレスインターフェイス上のワイヤレスプロファイルに関するより詳細な情報は、WlanGetProfile 関数を使用して取得できます。WlanGetProfileCustomUserData 関数を使用すると、ワイヤレスインターフェイス上のワイヤレスプロファイルのカスタムユーザーデータを取得できます。ローカルコンピューター上のワイヤレスインターフェイスと、それに関連付けられた GUID の一覧は、WlanEnumInterfaces 関数を使用して取得できます。

WlanGetProfileList 関数は、ppProfileList パラメーターが指すバッファーに返されるプロファイルの一覧用のメモリを割り当てます。このバッファーが不要になったら、呼び出し元が WlanFreeMemory 関数を使用してこのメモリを解放する必要があります。

Windows XP with SP3 および Wireless LAN API for Windows XP with SP2: ゲストプロファイル、Wireless Provisioning Service (WPS) 認証を使用するプロファイル、および Wi-Fi Protected Access-None (WPA-None) 認証を使用するプロファイルはサポートされていません。これらの種類のプロファイルは、優先プロファイル一覧に含まれていても WlanGetProfileList からは返されません。

例

次の例では、ローカルコンピューター上のワイヤレス LAN インターフェイスを列挙し、各ワイヤレス LAN インターフェイス上のプロファイルの一覧を取得して、取得した WLAN_PROFILE_INFO_LIST(WLAN_PROFILE_INFO エントリを格納します) の値を出力します。

注意 この例は、Wireless LAN サービスがインストールおよび開始されていない場合、Windows Server 2008 および Windows Server 2008 R2 では読み込みに失敗します。
#ifndef UNICODE
#define UNICODE
#endif

#include <windows.h>
#include <wlanapi.h>
#include <objbase.h>
#include <wtypes.h>

#include <stdio.h>
#include <stdlib.h>

// Need to link with Wlanapi.lib and Ole32.lib
#pragma comment(lib, "wlanapi.lib")
#pragma comment(lib, "ole32.lib")


int wmain()
{

    // Declare and initialize variables.

    HANDLE hClient = NULL;
    DWORD dwMaxClient = 2;      //    
    DWORD dwCurVersion = 0;
    DWORD dwResult = 0;
    DWORD dwRetVal = 0;
    int iRet = 0;
    
    WCHAR GuidString[39] = {0};

    unsigned int i, j;

    /* variables used for WlanEnumInterfaces  */

    PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
    PWLAN_INTERFACE_INFO pIfInfo = NULL;

    PWLAN_PROFILE_INFO_LIST pProfileList = NULL;
    PWLAN_PROFILE_INFO pProfile = NULL;

    dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
    if (dwResult != ERROR_SUCCESS) {
        wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
        return 1;
        // You can use FormatMessage here to find out why the function failed
    }

    dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
    if (dwResult != ERROR_SUCCESS) {
        wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
        return 1;
        // You can use FormatMessage here to find out why the function failed
    } else {
        wprintf(L"WLAN_INTERFACE_INFO_LIST for this system\n");

        wprintf(L"Num Entries: %lu\n", pIfList->dwNumberOfItems);
        wprintf(L"Current Index: %lu\n", pIfList->dwIndex);
        for (i = 0; i < (int) pIfList->dwNumberOfItems; i++) {
            pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i];
            wprintf(L"  Interface Index[%u]:\t %lu\n", i, i);
            iRet = StringFromGUID2(pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 
                sizeof(GuidString)/sizeof(*GuidString)); 
            // For c rather than C++ source code, the above line needs to be
            // iRet = StringFromGUID2(&pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 
            //     sizeof(GuidString)/sizeof(*GuidString)); 
            if (iRet == 0)
                wprintf(L"StringFromGUID2 failed\n");
            else {
                wprintf(L"  Interface GUID[%d]: %ws\n",i, GuidString);
            }    
            wprintf(L"  Interface Description[%d]: %ws", i, 
                pIfInfo->strInterfaceDescription);
            wprintf(L"\n");
            wprintf(L"  Interface State[%d]:\t ", i);
            switch (pIfInfo->isState) {
            case wlan_interface_state_not_ready:
                wprintf(L"Not ready\n");
                break;
            case wlan_interface_state_connected:
                wprintf(L"Connected\n");
                break;
            case wlan_interface_state_ad_hoc_network_formed:
                wprintf(L"First node in a ad hoc network\n");
                break;
            case wlan_interface_state_disconnecting:
                wprintf(L"Disconnecting\n");
                break;
            case wlan_interface_state_disconnected:
                wprintf(L"Not connected\n");
                break;
            case wlan_interface_state_associating:
                wprintf(L"Attempting to associate with a network\n");
                break;
            case wlan_interface_state_discovering:
                wprintf(L"Auto configuration is discovering settings for the network\n");
                break;
            case wlan_interface_state_authenticating:
                wprintf(L"In process of authenticating\n");
                break;
            default:
                wprintf(L"Unknown state %ld\n", pIfInfo->isState);
                break;
            }
            wprintf(L"\n");

            dwResult = WlanGetProfileList(hClient,
                                             &pIfInfo->InterfaceGuid,
                                             NULL, 
                                             &pProfileList);

            if (dwResult != ERROR_SUCCESS) {
                wprintf(L"WlanGetProfileList failed with error: %u\n",
                        dwResult);
                dwRetVal = 1;
                // You can use FormatMessage to find out why the function failed
            } else {
                wprintf(L"WLAN_PROFILE_INFO_LIST for this interface\n");

                wprintf(L"  Num Entries: %lu\n\n", pProfileList->dwNumberOfItems);

                for (j = 0; j < pProfileList->dwNumberOfItems; j++) {
                    pProfile =
                        (WLAN_PROFILE_INFO *) & pProfileList->ProfileInfo[j];

                    wprintf(L"  Profile Name[%u]:  %ws\n", j, pProfile->strProfileName);
                    
                    wprintf(L"  Flags[%u]:\t    0x%x", j, pProfile->dwFlags);
                    if (pProfile->dwFlags & WLAN_PROFILE_GROUP_POLICY)
                        wprintf(L"   Group Policy");
                    if (pProfile->dwFlags & WLAN_PROFILE_USER)
                        wprintf(L"   Per User Profile");
                    wprintf(L"\n");    

                    wprintf(L"\n");
                }
            }
        }

    }
    if (pProfileList != NULL) {
        WlanFreeMemory(pProfileList);
        pProfileList = NULL;
    }

    if (pIfList != NULL) {
        WlanFreeMemory(pIfList);
        pIfList = NULL;
    }

    return dwRetVal;
}
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// wlanapi.dll
#include <windows.h>

DWORD WlanGetProfileList(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    void* pReserved,   // optional
    WLAN_PROFILE_INFO_LIST** ppProfileList
);
[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanGetProfileList(
    IntPtr hClientHandle,   // HANDLE
    ref Guid pInterfaceGuid,   // GUID*
    IntPtr pReserved,   // void* optional
    IntPtr ppProfileList   // WLAN_PROFILE_INFO_LIST** out
);
<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanGetProfileList(
    hClientHandle As IntPtr,   ' HANDLE
    ByRef pInterfaceGuid As Guid,   ' GUID*
    pReserved As IntPtr,   ' void* optional
    ppProfileList As IntPtr   ' WLAN_PROFILE_INFO_LIST** out
) As UInteger
End Function
' hClientHandle : HANDLE
' pInterfaceGuid : GUID*
' pReserved : void* optional
' ppProfileList : WLAN_PROFILE_INFO_LIST** out
Declare PtrSafe Function WlanGetProfileList Lib "wlanapi" ( _
    ByVal hClientHandle As LongPtr, _
    ByVal pInterfaceGuid As LongPtr, _
    ByVal pReserved As LongPtr, _
    ByVal ppProfileList As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WlanGetProfileList = ctypes.windll.wlanapi.WlanGetProfileList
WlanGetProfileList.restype = wintypes.DWORD
WlanGetProfileList.argtypes = [
    wintypes.HANDLE,  # hClientHandle : HANDLE
    ctypes.c_void_p,  # pInterfaceGuid : GUID*
    ctypes.POINTER(None),  # pReserved : void* optional
    ctypes.c_void_p,  # ppProfileList : WLAN_PROFILE_INFO_LIST** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wlanapi.dll')
WlanGetProfileList = Fiddle::Function.new(
  lib['WlanGetProfileList'],
  [
    Fiddle::TYPE_VOIDP,  # hClientHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # pInterfaceGuid : GUID*
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional
    Fiddle::TYPE_VOIDP,  # ppProfileList : WLAN_PROFILE_INFO_LIST** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wlanapi")]
extern "system" {
    fn WlanGetProfileList(
        hClientHandle: *mut core::ffi::c_void,  // HANDLE
        pInterfaceGuid: *const GUID,  // GUID*
        pReserved: *mut (),  // void* optional
        ppProfileList: *mut *mut WLAN_PROFILE_INFO_LIST  // WLAN_PROFILE_INFO_LIST** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanGetProfileList(IntPtr hClientHandle, ref Guid pInterfaceGuid, IntPtr pReserved, IntPtr ppProfileList);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanGetProfileList' -Namespace Win32 -PassThru
# $api::WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
#uselib "wlanapi.dll"
#func global WlanGetProfileList "WlanGetProfileList" sptr, sptr, sptr, sptr
; WlanGetProfileList hClientHandle, varptr(pInterfaceGuid), pReserved, varptr(ppProfileList)   ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "sptr"
; pReserved : void* optional -> "sptr"
; ppProfileList : WLAN_PROFILE_INFO_LIST** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wlanapi.dll"
#cfunc global WlanGetProfileList "WlanGetProfileList" sptr, var, sptr, var
; res = WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "var"
; pReserved : void* optional -> "sptr"
; ppProfileList : WLAN_PROFILE_INFO_LIST** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WlanGetProfileList(HANDLE hClientHandle, GUID* pInterfaceGuid, void* pReserved, WLAN_PROFILE_INFO_LIST** ppProfileList)
#uselib "wlanapi.dll"
#cfunc global WlanGetProfileList "WlanGetProfileList" intptr, var, intptr, var
; res = WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
; hClientHandle : HANDLE -> "intptr"
; pInterfaceGuid : GUID* -> "var"
; pReserved : void* optional -> "intptr"
; ppProfileList : WLAN_PROFILE_INFO_LIST** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
	procWlanGetProfileList = wlanapi.NewProc("WlanGetProfileList")
)

// hClientHandle (HANDLE), pInterfaceGuid (GUID*), pReserved (void* optional), ppProfileList (WLAN_PROFILE_INFO_LIST** out)
r1, _, err := procWlanGetProfileList.Call(
	uintptr(hClientHandle),
	uintptr(pInterfaceGuid),
	uintptr(pReserved),
	uintptr(ppProfileList),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WlanGetProfileList(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  pReserved: Pointer;   // void* optional
  ppProfileList: Pointer   // WLAN_PROFILE_INFO_LIST** out
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanGetProfileList';
result := DllCall("wlanapi\WlanGetProfileList"
    , "Ptr", hClientHandle   ; HANDLE
    , "Ptr", pInterfaceGuid   ; GUID*
    , "Ptr", pReserved   ; void* optional
    , "Ptr", ppProfileList   ; WLAN_PROFILE_INFO_LIST** out
    , "UInt")   ; return: DWORD
●WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList) = DLL("wlanapi.dll", "dword WlanGetProfileList(void*, void*, void*, void*)")
# 呼び出し: WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
# hClientHandle : HANDLE -> "void*"
# pInterfaceGuid : GUID* -> "void*"
# pReserved : void* optional -> "void*"
# ppProfileList : WLAN_PROFILE_INFO_LIST** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wlanapi" fn WlanGetProfileList(
    hClientHandle: ?*anyopaque, // HANDLE
    pInterfaceGuid: [*c]GUID, // GUID*
    pReserved: ?*anyopaque, // void* optional
    ppProfileList: [*c][*c]WLAN_PROFILE_INFO_LIST // WLAN_PROFILE_INFO_LIST** out
) callconv(std.os.windows.WINAPI) u32;
proc WlanGetProfileList(
    hClientHandle: pointer,  # HANDLE
    pInterfaceGuid: ptr GUID,  # GUID*
    pReserved: pointer,  # void* optional
    ppProfileList: ptr WLAN_PROFILE_INFO_LIST  # WLAN_PROFILE_INFO_LIST** out
): uint32 {.importc: "WlanGetProfileList", stdcall, dynlib: "wlanapi.dll".}
pragma(lib, "wlanapi");
extern(Windows)
uint WlanGetProfileList(
    void* hClientHandle,   // HANDLE
    GUID* pInterfaceGuid,   // GUID*
    void* pReserved,   // void* optional
    WLAN_PROFILE_INFO_LIST** ppProfileList   // WLAN_PROFILE_INFO_LIST** out
);
ccall((:WlanGetProfileList, "wlanapi.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Ptr{GUID}, Ptr{Cvoid}, Ptr{WLAN_PROFILE_INFO_LIST}),
      hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
# hClientHandle : HANDLE -> Ptr{Cvoid}
# pInterfaceGuid : GUID* -> Ptr{GUID}
# pReserved : void* optional -> Ptr{Cvoid}
# ppProfileList : WLAN_PROFILE_INFO_LIST** out -> Ptr{WLAN_PROFILE_INFO_LIST}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WlanGetProfileList(
    void* hClientHandle,
    void* pInterfaceGuid,
    void* pReserved,
    void* ppProfileList);
]]
local wlanapi = ffi.load("wlanapi")
-- wlanapi.WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
-- hClientHandle : HANDLE
-- pInterfaceGuid : GUID*
-- pReserved : void* optional
-- ppProfileList : WLAN_PROFILE_INFO_LIST** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wlanapi.dll');
const WlanGetProfileList = lib.func('__stdcall', 'WlanGetProfileList', 'uint32_t', ['void *', 'void *', 'void *', 'void *']);
// WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
// hClientHandle : HANDLE -> 'void *'
// pInterfaceGuid : GUID* -> 'void *'
// pReserved : void* optional -> 'void *'
// ppProfileList : WLAN_PROFILE_INFO_LIST** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wlanapi.dll", {
  WlanGetProfileList: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList)
// hClientHandle : HANDLE -> "pointer"
// pInterfaceGuid : GUID* -> "pointer"
// pReserved : void* optional -> "pointer"
// ppProfileList : WLAN_PROFILE_INFO_LIST** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WlanGetProfileList(
    void* hClientHandle,
    void* pInterfaceGuid,
    void* pReserved,
    void* ppProfileList);
C, "wlanapi.dll");
// $ffi->WlanGetProfileList(hClientHandle, pInterfaceGuid, pReserved, ppProfileList);
// hClientHandle : HANDLE
// pInterfaceGuid : GUID*
// pReserved : void* optional
// ppProfileList : WLAN_PROFILE_INFO_LIST** out
// 構造体/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 WlanGetProfileList(
        Pointer hClientHandle,   // HANDLE
        Pointer pInterfaceGuid,   // GUID*
        Pointer pReserved,   // void* optional
        Pointer ppProfileList   // WLAN_PROFILE_INFO_LIST** out
    );
}
@[Link("wlanapi")]
lib Libwlanapi
  fun WlanGetProfileList = WlanGetProfileList(
    hClientHandle : Void*,   # HANDLE
    pInterfaceGuid : GUID*,   # GUID*
    pReserved : Void*,   # void* optional
    ppProfileList : WLAN_PROFILE_INFO_LIST**   # WLAN_PROFILE_INFO_LIST** out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WlanGetProfileListNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef WlanGetProfileListDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final WlanGetProfileList = DynamicLibrary.open('wlanapi.dll')
    .lookupFunction<WlanGetProfileListNative, WlanGetProfileListDart>('WlanGetProfileList');
// hClientHandle : HANDLE -> Pointer<Void>
// pInterfaceGuid : GUID* -> Pointer<Void>
// pReserved : void* optional -> Pointer<Void>
// ppProfileList : WLAN_PROFILE_INFO_LIST** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WlanGetProfileList(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  pReserved: Pointer;   // void* optional
  ppProfileList: Pointer   // WLAN_PROFILE_INFO_LIST** out
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanGetProfileList';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WlanGetProfileList"
  c_WlanGetProfileList :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Word32
-- hClientHandle : HANDLE -> Ptr ()
-- pInterfaceGuid : GUID* -> Ptr ()
-- pReserved : void* optional -> Ptr ()
-- ppProfileList : WLAN_PROFILE_INFO_LIST** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wlangetprofilelist =
  foreign "WlanGetProfileList"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* hClientHandle : HANDLE -> (ptr void) *)
(* pInterfaceGuid : GUID* -> (ptr void) *)
(* pReserved : void* optional -> (ptr void) *)
(* ppProfileList : WLAN_PROFILE_INFO_LIST** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wlanapi (t "wlanapi.dll"))
(cffi:use-foreign-library wlanapi)

(cffi:defcfun ("WlanGetProfileList" wlan-get-profile-list :convention :stdcall) :uint32
  (h-client-handle :pointer)   ; HANDLE
  (p-interface-guid :pointer)   ; GUID*
  (p-reserved :pointer)   ; void* optional
  (pp-profile-list :pointer))   ; WLAN_PROFILE_INFO_LIST** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WlanGetProfileList = Win32::API::More->new('wlanapi',
    'DWORD WlanGetProfileList(HANDLE hClientHandle, LPVOID pInterfaceGuid, LPVOID pReserved, LPVOID ppProfileList)');
# my $ret = $WlanGetProfileList->Call($hClientHandle, $pInterfaceGuid, $pReserved, $ppProfileList);
# hClientHandle : HANDLE -> HANDLE
# pInterfaceGuid : GUID* -> LPVOID
# pReserved : void* optional -> LPVOID
# ppProfileList : WLAN_PROFILE_INFO_LIST** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型