ホーム › Devices.DeviceAndDriverInstallation › SetupDiGetHwProfileListExW
SetupDiGetHwProfileListExW
関数リモート対応でハードウェアプロファイル一覧を取得する。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupDiGetHwProfileListExW(
DWORD* HwProfileList,
DWORD HwProfileListSize,
DWORD* RequiredSize,
DWORD* CurrentlyActiveIndex, // optional
LPCWSTR MachineName, // optional
void* Reserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| HwProfileList | DWORD* | out | ハードウェアプロファイルID配列を受け取るバッファ。 |
| HwProfileListSize | DWORD | in | HwProfileList配列が保持できる要素数。 |
| RequiredSize | DWORD* | out | 実際に必要な要素数を受け取るポインタ。サイズ照会に使う。 |
| CurrentlyActiveIndex | DWORD* | outoptional | 現在アクティブなプロファイルの配列内インデックスを受け取るポインタ。 |
| MachineName | LPCWSTR | inoptional | 対象リモートコンピュータ名(Unicode)。NULL指定でローカルマシンを対象とする。 |
| Reserved | void* | optional | 予約済み。NULLを指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupDiGetHwProfileListExW(
DWORD* HwProfileList,
DWORD HwProfileListSize,
DWORD* RequiredSize,
DWORD* CurrentlyActiveIndex, // optional
LPCWSTR MachineName, // optional
void* Reserved // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupDiGetHwProfileListExW(
out uint HwProfileList, // DWORD* out
uint HwProfileListSize, // DWORD
out uint RequiredSize, // DWORD* out
IntPtr CurrentlyActiveIndex, // DWORD* optional, out
[MarshalAs(UnmanagedType.LPWStr)] string MachineName, // LPCWSTR optional
IntPtr Reserved // void* optional
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDiGetHwProfileListExW(
<Out> ByRef HwProfileList As UInteger, ' DWORD* out
HwProfileListSize As UInteger, ' DWORD
<Out> ByRef RequiredSize As UInteger, ' DWORD* out
CurrentlyActiveIndex As IntPtr, ' DWORD* optional, out
<MarshalAs(UnmanagedType.LPWStr)> MachineName As String, ' LPCWSTR optional
Reserved As IntPtr ' void* optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' HwProfileList : DWORD* out
' HwProfileListSize : DWORD
' RequiredSize : DWORD* out
' CurrentlyActiveIndex : DWORD* optional, out
' MachineName : LPCWSTR optional
' Reserved : void* optional
Declare PtrSafe Function SetupDiGetHwProfileListExW Lib "setupapi" ( _
ByRef HwProfileList As Long, _
ByVal HwProfileListSize As Long, _
ByRef RequiredSize As Long, _
ByVal CurrentlyActiveIndex As LongPtr, _
ByVal MachineName As LongPtr, _
ByVal Reserved As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupDiGetHwProfileListExW = ctypes.windll.setupapi.SetupDiGetHwProfileListExW
SetupDiGetHwProfileListExW.restype = wintypes.BOOL
SetupDiGetHwProfileListExW.argtypes = [
ctypes.POINTER(wintypes.DWORD), # HwProfileList : DWORD* out
wintypes.DWORD, # HwProfileListSize : DWORD
ctypes.POINTER(wintypes.DWORD), # RequiredSize : DWORD* out
ctypes.POINTER(wintypes.DWORD), # CurrentlyActiveIndex : DWORD* optional, out
wintypes.LPCWSTR, # MachineName : LPCWSTR optional
ctypes.POINTER(None), # Reserved : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiGetHwProfileListExW = Fiddle::Function.new(
lib['SetupDiGetHwProfileListExW'],
[
Fiddle::TYPE_VOIDP, # HwProfileList : DWORD* out
-Fiddle::TYPE_INT, # HwProfileListSize : DWORD
Fiddle::TYPE_VOIDP, # RequiredSize : DWORD* out
Fiddle::TYPE_VOIDP, # CurrentlyActiveIndex : DWORD* optional, out
Fiddle::TYPE_VOIDP, # MachineName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # Reserved : void* optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupDiGetHwProfileListExW(
HwProfileList: *mut u32, // DWORD* out
HwProfileListSize: u32, // DWORD
RequiredSize: *mut u32, // DWORD* out
CurrentlyActiveIndex: *mut u32, // DWORD* optional, out
MachineName: *const u16, // LPCWSTR optional
Reserved: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupDiGetHwProfileListExW(out uint HwProfileList, uint HwProfileListSize, out uint RequiredSize, IntPtr CurrentlyActiveIndex, [MarshalAs(UnmanagedType.LPWStr)] string MachineName, IntPtr Reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiGetHwProfileListExW' -Namespace Win32 -PassThru
# $api::SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved)#uselib "SETUPAPI.dll"
#func global SetupDiGetHwProfileListExW "SetupDiGetHwProfileListExW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupDiGetHwProfileListExW varptr(HwProfileList), HwProfileListSize, varptr(RequiredSize), varptr(CurrentlyActiveIndex), MachineName, Reserved ; 戻り値は stat
; HwProfileList : DWORD* out -> "wptr"
; HwProfileListSize : DWORD -> "wptr"
; RequiredSize : DWORD* out -> "wptr"
; CurrentlyActiveIndex : DWORD* optional, out -> "wptr"
; MachineName : LPCWSTR optional -> "wptr"
; Reserved : void* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupDiGetHwProfileListExW "SetupDiGetHwProfileListExW" var, int, var, var, wstr, sptr ; res = SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved) ; HwProfileList : DWORD* out -> "var" ; HwProfileListSize : DWORD -> "int" ; RequiredSize : DWORD* out -> "var" ; CurrentlyActiveIndex : DWORD* optional, out -> "var" ; MachineName : LPCWSTR optional -> "wstr" ; Reserved : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupDiGetHwProfileListExW "SetupDiGetHwProfileListExW" sptr, int, sptr, sptr, wstr, sptr ; res = SetupDiGetHwProfileListExW(varptr(HwProfileList), HwProfileListSize, varptr(RequiredSize), varptr(CurrentlyActiveIndex), MachineName, Reserved) ; HwProfileList : DWORD* out -> "sptr" ; HwProfileListSize : DWORD -> "int" ; RequiredSize : DWORD* out -> "sptr" ; CurrentlyActiveIndex : DWORD* optional, out -> "sptr" ; MachineName : LPCWSTR optional -> "wstr" ; Reserved : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupDiGetHwProfileListExW(DWORD* HwProfileList, DWORD HwProfileListSize, DWORD* RequiredSize, DWORD* CurrentlyActiveIndex, LPCWSTR MachineName, void* Reserved) #uselib "SETUPAPI.dll" #cfunc global SetupDiGetHwProfileListExW "SetupDiGetHwProfileListExW" var, int, var, var, wstr, intptr ; res = SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved) ; HwProfileList : DWORD* out -> "var" ; HwProfileListSize : DWORD -> "int" ; RequiredSize : DWORD* out -> "var" ; CurrentlyActiveIndex : DWORD* optional, out -> "var" ; MachineName : LPCWSTR optional -> "wstr" ; Reserved : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupDiGetHwProfileListExW(DWORD* HwProfileList, DWORD HwProfileListSize, DWORD* RequiredSize, DWORD* CurrentlyActiveIndex, LPCWSTR MachineName, void* Reserved) #uselib "SETUPAPI.dll" #cfunc global SetupDiGetHwProfileListExW "SetupDiGetHwProfileListExW" intptr, int, intptr, intptr, wstr, intptr ; res = SetupDiGetHwProfileListExW(varptr(HwProfileList), HwProfileListSize, varptr(RequiredSize), varptr(CurrentlyActiveIndex), MachineName, Reserved) ; HwProfileList : DWORD* out -> "intptr" ; HwProfileListSize : DWORD -> "int" ; RequiredSize : DWORD* out -> "intptr" ; CurrentlyActiveIndex : DWORD* optional, out -> "intptr" ; MachineName : LPCWSTR optional -> "wstr" ; Reserved : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupDiGetHwProfileListExW = setupapi.NewProc("SetupDiGetHwProfileListExW")
)
// HwProfileList (DWORD* out), HwProfileListSize (DWORD), RequiredSize (DWORD* out), CurrentlyActiveIndex (DWORD* optional, out), MachineName (LPCWSTR optional), Reserved (void* optional)
r1, _, err := procSetupDiGetHwProfileListExW.Call(
uintptr(HwProfileList),
uintptr(HwProfileListSize),
uintptr(RequiredSize),
uintptr(CurrentlyActiveIndex),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(MachineName))),
uintptr(Reserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupDiGetHwProfileListExW(
HwProfileList: Pointer; // DWORD* out
HwProfileListSize: DWORD; // DWORD
RequiredSize: Pointer; // DWORD* out
CurrentlyActiveIndex: Pointer; // DWORD* optional, out
MachineName: PWideChar; // LPCWSTR optional
Reserved: Pointer // void* optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiGetHwProfileListExW';result := DllCall("SETUPAPI\SetupDiGetHwProfileListExW"
, "Ptr", HwProfileList ; DWORD* out
, "UInt", HwProfileListSize ; DWORD
, "Ptr", RequiredSize ; DWORD* out
, "Ptr", CurrentlyActiveIndex ; DWORD* optional, out
, "WStr", MachineName ; LPCWSTR optional
, "Ptr", Reserved ; void* optional
, "Int") ; return: BOOL●SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved) = DLL("SETUPAPI.dll", "bool SetupDiGetHwProfileListExW(void*, dword, void*, void*, char*, void*)")
# 呼び出し: SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved)
# HwProfileList : DWORD* out -> "void*"
# HwProfileListSize : DWORD -> "dword"
# RequiredSize : DWORD* out -> "void*"
# CurrentlyActiveIndex : DWORD* optional, out -> "void*"
# MachineName : LPCWSTR optional -> "char*"
# Reserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupDiGetHwProfileListExW(
HwProfileList: [*c]u32, // DWORD* out
HwProfileListSize: u32, // DWORD
RequiredSize: [*c]u32, // DWORD* out
CurrentlyActiveIndex: [*c]u32, // DWORD* optional, out
MachineName: [*c]const u16, // LPCWSTR optional
Reserved: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupDiGetHwProfileListExW(
HwProfileList: ptr uint32, # DWORD* out
HwProfileListSize: uint32, # DWORD
RequiredSize: ptr uint32, # DWORD* out
CurrentlyActiveIndex: ptr uint32, # DWORD* optional, out
MachineName: WideCString, # LPCWSTR optional
Reserved: pointer # void* optional
): int32 {.importc: "SetupDiGetHwProfileListExW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupDiGetHwProfileListExW(
uint* HwProfileList, // DWORD* out
uint HwProfileListSize, // DWORD
uint* RequiredSize, // DWORD* out
uint* CurrentlyActiveIndex, // DWORD* optional, out
const(wchar)* MachineName, // LPCWSTR optional
void* Reserved // void* optional
);ccall((:SetupDiGetHwProfileListExW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{UInt32}, UInt32, Ptr{UInt32}, Ptr{UInt32}, Cwstring, Ptr{Cvoid}),
HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved)
# HwProfileList : DWORD* out -> Ptr{UInt32}
# HwProfileListSize : DWORD -> UInt32
# RequiredSize : DWORD* out -> Ptr{UInt32}
# CurrentlyActiveIndex : DWORD* optional, out -> Ptr{UInt32}
# MachineName : LPCWSTR optional -> Cwstring
# Reserved : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupDiGetHwProfileListExW(
uint32_t* HwProfileList,
uint32_t HwProfileListSize,
uint32_t* RequiredSize,
uint32_t* CurrentlyActiveIndex,
const uint16_t* MachineName,
void* Reserved);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved)
-- HwProfileList : DWORD* out
-- HwProfileListSize : DWORD
-- RequiredSize : DWORD* out
-- CurrentlyActiveIndex : DWORD* optional, out
-- MachineName : LPCWSTR optional
-- Reserved : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupDiGetHwProfileListExW = lib.func('__stdcall', 'SetupDiGetHwProfileListExW', 'int32_t', ['uint32_t *', 'uint32_t', 'uint32_t *', 'uint32_t *', 'str16', 'void *']);
// SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved)
// HwProfileList : DWORD* out -> 'uint32_t *'
// HwProfileListSize : DWORD -> 'uint32_t'
// RequiredSize : DWORD* out -> 'uint32_t *'
// CurrentlyActiveIndex : DWORD* optional, out -> 'uint32_t *'
// MachineName : LPCWSTR optional -> 'str16'
// Reserved : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupDiGetHwProfileListExW: { parameters: ["pointer", "u32", "pointer", "pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved)
// HwProfileList : DWORD* out -> "pointer"
// HwProfileListSize : DWORD -> "u32"
// RequiredSize : DWORD* out -> "pointer"
// CurrentlyActiveIndex : DWORD* optional, out -> "pointer"
// MachineName : LPCWSTR optional -> "buffer"
// Reserved : void* optional -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupDiGetHwProfileListExW(
uint32_t* HwProfileList,
uint32_t HwProfileListSize,
uint32_t* RequiredSize,
uint32_t* CurrentlyActiveIndex,
const uint16_t* MachineName,
void* Reserved);
C, "SETUPAPI.dll");
// $ffi->SetupDiGetHwProfileListExW(HwProfileList, HwProfileListSize, RequiredSize, CurrentlyActiveIndex, MachineName, Reserved);
// HwProfileList : DWORD* out
// HwProfileListSize : DWORD
// RequiredSize : DWORD* out
// CurrentlyActiveIndex : DWORD* optional, out
// MachineName : LPCWSTR optional
// Reserved : 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 Setupapi extends StdCallLibrary {
Setupapi INSTANCE = Native.load("setupapi", Setupapi.class, W32APIOptions.UNICODE_OPTIONS);
boolean SetupDiGetHwProfileListExW(
IntByReference HwProfileList, // DWORD* out
int HwProfileListSize, // DWORD
IntByReference RequiredSize, // DWORD* out
IntByReference CurrentlyActiveIndex, // DWORD* optional, out
WString MachineName, // LPCWSTR optional
Pointer Reserved // void* optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupDiGetHwProfileListExW = SetupDiGetHwProfileListExW(
HwProfileList : UInt32*, # DWORD* out
HwProfileListSize : UInt32, # DWORD
RequiredSize : UInt32*, # DWORD* out
CurrentlyActiveIndex : UInt32*, # DWORD* optional, out
MachineName : UInt16*, # LPCWSTR optional
Reserved : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupDiGetHwProfileListExWNative = Int32 Function(Pointer<Uint32>, Uint32, Pointer<Uint32>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Void>);
typedef SetupDiGetHwProfileListExWDart = int Function(Pointer<Uint32>, int, Pointer<Uint32>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Void>);
final SetupDiGetHwProfileListExW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupDiGetHwProfileListExWNative, SetupDiGetHwProfileListExWDart>('SetupDiGetHwProfileListExW');
// HwProfileList : DWORD* out -> Pointer<Uint32>
// HwProfileListSize : DWORD -> Uint32
// RequiredSize : DWORD* out -> Pointer<Uint32>
// CurrentlyActiveIndex : DWORD* optional, out -> Pointer<Uint32>
// MachineName : LPCWSTR optional -> Pointer<Utf16>
// Reserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupDiGetHwProfileListExW(
HwProfileList: Pointer; // DWORD* out
HwProfileListSize: DWORD; // DWORD
RequiredSize: Pointer; // DWORD* out
CurrentlyActiveIndex: Pointer; // DWORD* optional, out
MachineName: PWideChar; // LPCWSTR optional
Reserved: Pointer // void* optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiGetHwProfileListExW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupDiGetHwProfileListExW"
c_SetupDiGetHwProfileListExW :: Ptr Word32 -> Word32 -> Ptr Word32 -> Ptr Word32 -> CWString -> Ptr () -> IO CInt
-- HwProfileList : DWORD* out -> Ptr Word32
-- HwProfileListSize : DWORD -> Word32
-- RequiredSize : DWORD* out -> Ptr Word32
-- CurrentlyActiveIndex : DWORD* optional, out -> Ptr Word32
-- MachineName : LPCWSTR optional -> CWString
-- Reserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupdigethwprofilelistexw =
foreign "SetupDiGetHwProfileListExW"
((ptr uint32_t) @-> uint32_t @-> (ptr uint32_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* HwProfileList : DWORD* out -> (ptr uint32_t) *)
(* HwProfileListSize : DWORD -> uint32_t *)
(* RequiredSize : DWORD* out -> (ptr uint32_t) *)
(* CurrentlyActiveIndex : DWORD* optional, out -> (ptr uint32_t) *)
(* MachineName : LPCWSTR optional -> (ptr uint16_t) *)
(* Reserved : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupDiGetHwProfileListExW" setup-di-get-hw-profile-list-ex-w :convention :stdcall) :int32
(hw-profile-list :pointer) ; DWORD* out
(hw-profile-list-size :uint32) ; DWORD
(required-size :pointer) ; DWORD* out
(currently-active-index :pointer) ; DWORD* optional, out
(machine-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(reserved :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupDiGetHwProfileListExW = Win32::API::More->new('SETUPAPI',
'BOOL SetupDiGetHwProfileListExW(LPVOID HwProfileList, DWORD HwProfileListSize, LPVOID RequiredSize, LPVOID CurrentlyActiveIndex, LPCWSTR MachineName, LPVOID Reserved)');
# my $ret = $SetupDiGetHwProfileListExW->Call($HwProfileList, $HwProfileListSize, $RequiredSize, $CurrentlyActiveIndex, $MachineName, $Reserved);
# HwProfileList : DWORD* out -> LPVOID
# HwProfileListSize : DWORD -> DWORD
# RequiredSize : DWORD* out -> LPVOID
# CurrentlyActiveIndex : DWORD* optional, out -> LPVOID
# MachineName : LPCWSTR optional -> LPCWSTR
# Reserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupDiGetHwProfileListExA (ANSI版) — リモート対応でハードウェアプロファイル一覧を取得する。
類似 API
- f SetupDiGetHwProfileList — システムのハードウェアプロファイル一覧を取得する。