ホーム › Devices.DeviceAndDriverInstallation › CM_Get_Device_ID_Size
CM_Get_Device_ID_Size
関数デバイスインスタンスIDの文字数を取得する。
シグネチャ
// CFGMGR32.dll
#include <windows.h>
CONFIGRET CM_Get_Device_ID_Size(
DWORD* pulLen,
DWORD dnDevInst,
DWORD ulFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pulLen | DWORD* | out |
| dnDevInst | DWORD | in |
| ulFlags | DWORD | in |
戻り値の型: CONFIGRET
各言語での呼び出し定義
// CFGMGR32.dll
#include <windows.h>
CONFIGRET CM_Get_Device_ID_Size(
DWORD* pulLen,
DWORD dnDevInst,
DWORD ulFlags
);[DllImport("CFGMGR32.dll", ExactSpelling = true)]
static extern uint CM_Get_Device_ID_Size(
out uint pulLen, // DWORD* out
uint dnDevInst, // DWORD
uint ulFlags // DWORD
);<DllImport("CFGMGR32.dll", ExactSpelling:=True)>
Public Shared Function CM_Get_Device_ID_Size(
<Out> ByRef pulLen As UInteger, ' DWORD* out
dnDevInst As UInteger, ' DWORD
ulFlags As UInteger ' DWORD
) As UInteger
End Function' pulLen : DWORD* out
' dnDevInst : DWORD
' ulFlags : DWORD
Declare PtrSafe Function CM_Get_Device_ID_Size Lib "cfgmgr32" ( _
ByRef pulLen As Long, _
ByVal dnDevInst 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_ID_Size = ctypes.windll.cfgmgr32.CM_Get_Device_ID_Size
CM_Get_Device_ID_Size.restype = wintypes.DWORD
CM_Get_Device_ID_Size.argtypes = [
ctypes.POINTER(wintypes.DWORD), # pulLen : DWORD* out
wintypes.DWORD, # dnDevInst : DWORD
wintypes.DWORD, # ulFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Get_Device_ID_Size = Fiddle::Function.new(
lib['CM_Get_Device_ID_Size'],
[
Fiddle::TYPE_VOIDP, # pulLen : DWORD* out
-Fiddle::TYPE_INT, # dnDevInst : DWORD
-Fiddle::TYPE_INT, # ulFlags : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "cfgmgr32")]
extern "system" {
fn CM_Get_Device_ID_Size(
pulLen: *mut u32, // DWORD* out
dnDevInst: u32, // DWORD
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_ID_Size(out uint pulLen, uint dnDevInst, uint ulFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Get_Device_ID_Size' -Namespace Win32 -PassThru
# $api::CM_Get_Device_ID_Size(pulLen, dnDevInst, ulFlags)#uselib "CFGMGR32.dll"
#func global CM_Get_Device_ID_Size "CM_Get_Device_ID_Size" sptr, sptr, sptr
; CM_Get_Device_ID_Size varptr(pulLen), dnDevInst, ulFlags ; 戻り値は stat
; pulLen : DWORD* out -> "sptr"
; dnDevInst : DWORD -> "sptr"
; ulFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CFGMGR32.dll" #cfunc global CM_Get_Device_ID_Size "CM_Get_Device_ID_Size" var, int, int ; res = CM_Get_Device_ID_Size(pulLen, dnDevInst, ulFlags) ; pulLen : DWORD* out -> "var" ; dnDevInst : DWORD -> "int" ; ulFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CFGMGR32.dll" #cfunc global CM_Get_Device_ID_Size "CM_Get_Device_ID_Size" sptr, int, int ; res = CM_Get_Device_ID_Size(varptr(pulLen), dnDevInst, ulFlags) ; pulLen : DWORD* out -> "sptr" ; dnDevInst : DWORD -> "int" ; ulFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; CONFIGRET CM_Get_Device_ID_Size(DWORD* pulLen, DWORD dnDevInst, DWORD ulFlags) #uselib "CFGMGR32.dll" #cfunc global CM_Get_Device_ID_Size "CM_Get_Device_ID_Size" var, int, int ; res = CM_Get_Device_ID_Size(pulLen, dnDevInst, ulFlags) ; pulLen : DWORD* out -> "var" ; dnDevInst : DWORD -> "int" ; ulFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; CONFIGRET CM_Get_Device_ID_Size(DWORD* pulLen, DWORD dnDevInst, DWORD ulFlags) #uselib "CFGMGR32.dll" #cfunc global CM_Get_Device_ID_Size "CM_Get_Device_ID_Size" intptr, int, int ; res = CM_Get_Device_ID_Size(varptr(pulLen), dnDevInst, ulFlags) ; pulLen : DWORD* out -> "intptr" ; dnDevInst : DWORD -> "int" ; ulFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
procCM_Get_Device_ID_Size = cfgmgr32.NewProc("CM_Get_Device_ID_Size")
)
// pulLen (DWORD* out), dnDevInst (DWORD), ulFlags (DWORD)
r1, _, err := procCM_Get_Device_ID_Size.Call(
uintptr(pulLen),
uintptr(dnDevInst),
uintptr(ulFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // CONFIGRETfunction CM_Get_Device_ID_Size(
pulLen: Pointer; // DWORD* out
dnDevInst: DWORD; // DWORD
ulFlags: DWORD // DWORD
): DWORD; stdcall;
external 'CFGMGR32.dll' name 'CM_Get_Device_ID_Size';result := DllCall("CFGMGR32\CM_Get_Device_ID_Size"
, "Ptr", pulLen ; DWORD* out
, "UInt", dnDevInst ; DWORD
, "UInt", ulFlags ; DWORD
, "UInt") ; return: CONFIGRET●CM_Get_Device_ID_Size(pulLen, dnDevInst, ulFlags) = DLL("CFGMGR32.dll", "dword CM_Get_Device_ID_Size(void*, dword, dword)")
# 呼び出し: CM_Get_Device_ID_Size(pulLen, dnDevInst, ulFlags)
# pulLen : DWORD* out -> "void*"
# dnDevInst : DWORD -> "dword"
# ulFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。