Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › CM_Get_Device_Interface_Property_KeysW

CM_Get_Device_Interface_Property_KeysW

関数
デバイスインターフェイスのプロパティキー一覧を取得する。
DLLCFGMGR32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

CONFIGRET CM_Get_Device_Interface_Property_KeysW(
    LPCWSTR pszDeviceInterface,
    DEVPROPKEY* PropertyKeyArray,   // optional
    DWORD* PropertyKeyCount,
    DWORD ulFlags
);

パラメーター

名前方向
pszDeviceInterfaceLPCWSTRin
PropertyKeyArrayDEVPROPKEY*outoptional
PropertyKeyCountDWORD*inout
ulFlagsDWORDin

戻り値の型: CONFIGRET

各言語での呼び出し定義

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

CONFIGRET CM_Get_Device_Interface_Property_KeysW(
    LPCWSTR pszDeviceInterface,
    DEVPROPKEY* PropertyKeyArray,   // optional
    DWORD* PropertyKeyCount,
    DWORD ulFlags
);
[DllImport("CFGMGR32.dll", ExactSpelling = true)]
static extern uint CM_Get_Device_Interface_Property_KeysW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszDeviceInterface,   // LPCWSTR
    IntPtr PropertyKeyArray,   // DEVPROPKEY* optional, out
    ref uint PropertyKeyCount,   // DWORD* in/out
    uint ulFlags   // DWORD
);
<DllImport("CFGMGR32.dll", ExactSpelling:=True)>
Public Shared Function CM_Get_Device_Interface_Property_KeysW(
    <MarshalAs(UnmanagedType.LPWStr)> pszDeviceInterface As String,   ' LPCWSTR
    PropertyKeyArray As IntPtr,   ' DEVPROPKEY* optional, out
    ByRef PropertyKeyCount As UInteger,   ' DWORD* in/out
    ulFlags As UInteger   ' DWORD
) As UInteger
End Function
' pszDeviceInterface : LPCWSTR
' PropertyKeyArray : DEVPROPKEY* optional, out
' PropertyKeyCount : DWORD* in/out
' ulFlags : DWORD
Declare PtrSafe Function CM_Get_Device_Interface_Property_KeysW Lib "cfgmgr32" ( _
    ByVal pszDeviceInterface As LongPtr, _
    ByVal PropertyKeyArray As LongPtr, _
    ByRef PropertyKeyCount As Long, _
    ByVal ulFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CM_Get_Device_Interface_Property_KeysW = ctypes.windll.cfgmgr32.CM_Get_Device_Interface_Property_KeysW
CM_Get_Device_Interface_Property_KeysW.restype = wintypes.DWORD
CM_Get_Device_Interface_Property_KeysW.argtypes = [
    wintypes.LPCWSTR,  # pszDeviceInterface : LPCWSTR
    ctypes.c_void_p,  # PropertyKeyArray : DEVPROPKEY* optional, out
    ctypes.POINTER(wintypes.DWORD),  # PropertyKeyCount : DWORD* in/out
    wintypes.DWORD,  # ulFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Get_Device_Interface_Property_KeysW = Fiddle::Function.new(
  lib['CM_Get_Device_Interface_Property_KeysW'],
  [
    Fiddle::TYPE_VOIDP,  # pszDeviceInterface : LPCWSTR
    Fiddle::TYPE_VOIDP,  # PropertyKeyArray : DEVPROPKEY* optional, out
    Fiddle::TYPE_VOIDP,  # PropertyKeyCount : DWORD* in/out
    -Fiddle::TYPE_INT,  # ulFlags : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "cfgmgr32")]
extern "system" {
    fn CM_Get_Device_Interface_Property_KeysW(
        pszDeviceInterface: *const u16,  // LPCWSTR
        PropertyKeyArray: *mut DEVPROPKEY,  // DEVPROPKEY* optional, out
        PropertyKeyCount: *mut u32,  // DWORD* in/out
        ulFlags: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CFGMGR32.dll")]
public static extern uint CM_Get_Device_Interface_Property_KeysW([MarshalAs(UnmanagedType.LPWStr)] string pszDeviceInterface, IntPtr PropertyKeyArray, ref uint PropertyKeyCount, uint ulFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Get_Device_Interface_Property_KeysW' -Namespace Win32 -PassThru
# $api::CM_Get_Device_Interface_Property_KeysW(pszDeviceInterface, PropertyKeyArray, PropertyKeyCount, ulFlags)
#uselib "CFGMGR32.dll"
#func global CM_Get_Device_Interface_Property_KeysW "CM_Get_Device_Interface_Property_KeysW" sptr, sptr, sptr, sptr
; CM_Get_Device_Interface_Property_KeysW pszDeviceInterface, varptr(PropertyKeyArray), varptr(PropertyKeyCount), ulFlags   ; 戻り値は stat
; pszDeviceInterface : LPCWSTR -> "sptr"
; PropertyKeyArray : DEVPROPKEY* optional, out -> "sptr"
; PropertyKeyCount : DWORD* in/out -> "sptr"
; ulFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_Device_Interface_Property_KeysW "CM_Get_Device_Interface_Property_KeysW" wstr, var, var, int
; res = CM_Get_Device_Interface_Property_KeysW(pszDeviceInterface, PropertyKeyArray, PropertyKeyCount, ulFlags)
; pszDeviceInterface : LPCWSTR -> "wstr"
; PropertyKeyArray : DEVPROPKEY* optional, out -> "var"
; PropertyKeyCount : DWORD* in/out -> "var"
; ulFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; CONFIGRET CM_Get_Device_Interface_Property_KeysW(LPCWSTR pszDeviceInterface, DEVPROPKEY* PropertyKeyArray, DWORD* PropertyKeyCount, DWORD ulFlags)
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_Device_Interface_Property_KeysW "CM_Get_Device_Interface_Property_KeysW" wstr, var, var, int
; res = CM_Get_Device_Interface_Property_KeysW(pszDeviceInterface, PropertyKeyArray, PropertyKeyCount, ulFlags)
; pszDeviceInterface : LPCWSTR -> "wstr"
; PropertyKeyArray : DEVPROPKEY* optional, out -> "var"
; PropertyKeyCount : DWORD* in/out -> "var"
; ulFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
	procCM_Get_Device_Interface_Property_KeysW = cfgmgr32.NewProc("CM_Get_Device_Interface_Property_KeysW")
)

// pszDeviceInterface (LPCWSTR), PropertyKeyArray (DEVPROPKEY* optional, out), PropertyKeyCount (DWORD* in/out), ulFlags (DWORD)
r1, _, err := procCM_Get_Device_Interface_Property_KeysW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDeviceInterface))),
	uintptr(PropertyKeyArray),
	uintptr(PropertyKeyCount),
	uintptr(ulFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CONFIGRET
function CM_Get_Device_Interface_Property_KeysW(
  pszDeviceInterface: PWideChar;   // LPCWSTR
  PropertyKeyArray: Pointer;   // DEVPROPKEY* optional, out
  PropertyKeyCount: Pointer;   // DWORD* in/out
  ulFlags: DWORD   // DWORD
): DWORD; stdcall;
  external 'CFGMGR32.dll' name 'CM_Get_Device_Interface_Property_KeysW';
result := DllCall("CFGMGR32\CM_Get_Device_Interface_Property_KeysW"
    , "WStr", pszDeviceInterface   ; LPCWSTR
    , "Ptr", PropertyKeyArray   ; DEVPROPKEY* optional, out
    , "Ptr", PropertyKeyCount   ; DWORD* in/out
    , "UInt", ulFlags   ; DWORD
    , "UInt")   ; return: CONFIGRET
●CM_Get_Device_Interface_Property_KeysW(pszDeviceInterface, PropertyKeyArray, PropertyKeyCount, ulFlags) = DLL("CFGMGR32.dll", "dword CM_Get_Device_Interface_Property_KeysW(char*, void*, void*, dword)")
# 呼び出し: CM_Get_Device_Interface_Property_KeysW(pszDeviceInterface, PropertyKeyArray, PropertyKeyCount, ulFlags)
# pszDeviceInterface : LPCWSTR -> "char*"
# PropertyKeyArray : DEVPROPKEY* optional, out -> "void*"
# PropertyKeyCount : DWORD* in/out -> "void*"
# ulFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。