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

CM_Get_Device_Interface_AliasA

関数
デバイスインターフェイスの別名インターフェイスを取得する。
DLLCFGMGR32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// CFGMGR32.dll  (ANSI / -A)
#include <windows.h>

CONFIGRET CM_Get_Device_Interface_AliasA(
    LPCSTR pszDeviceInterface,
    GUID* AliasInterfaceGuid,
    LPSTR pszAliasDeviceInterface,
    DWORD* pulLength,
    DWORD ulFlags
);

パラメーター

名前方向
pszDeviceInterfaceLPCSTRin
AliasInterfaceGuidGUID*in
pszAliasDeviceInterfaceLPSTRout
pulLengthDWORD*inout
ulFlagsDWORDin

戻り値の型: CONFIGRET

各言語での呼び出し定義

// CFGMGR32.dll  (ANSI / -A)
#include <windows.h>

CONFIGRET CM_Get_Device_Interface_AliasA(
    LPCSTR pszDeviceInterface,
    GUID* AliasInterfaceGuid,
    LPSTR pszAliasDeviceInterface,
    DWORD* pulLength,
    DWORD ulFlags
);
[DllImport("CFGMGR32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint CM_Get_Device_Interface_AliasA(
    [MarshalAs(UnmanagedType.LPStr)] string pszDeviceInterface,   // LPCSTR
    ref Guid AliasInterfaceGuid,   // GUID*
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszAliasDeviceInterface,   // LPSTR out
    ref uint pulLength,   // DWORD* in/out
    uint ulFlags   // DWORD
);
<DllImport("CFGMGR32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function CM_Get_Device_Interface_AliasA(
    <MarshalAs(UnmanagedType.LPStr)> pszDeviceInterface As String,   ' LPCSTR
    ByRef AliasInterfaceGuid As Guid,   ' GUID*
    <MarshalAs(UnmanagedType.LPStr)> pszAliasDeviceInterface As System.Text.StringBuilder,   ' LPSTR out
    ByRef pulLength As UInteger,   ' DWORD* in/out
    ulFlags As UInteger   ' DWORD
) As UInteger
End Function
' pszDeviceInterface : LPCSTR
' AliasInterfaceGuid : GUID*
' pszAliasDeviceInterface : LPSTR out
' pulLength : DWORD* in/out
' ulFlags : DWORD
Declare PtrSafe Function CM_Get_Device_Interface_AliasA Lib "cfgmgr32" ( _
    ByVal pszDeviceInterface As String, _
    ByVal AliasInterfaceGuid As LongPtr, _
    ByVal pszAliasDeviceInterface As String, _
    ByRef pulLength 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_AliasA = ctypes.windll.cfgmgr32.CM_Get_Device_Interface_AliasA
CM_Get_Device_Interface_AliasA.restype = wintypes.DWORD
CM_Get_Device_Interface_AliasA.argtypes = [
    wintypes.LPCSTR,  # pszDeviceInterface : LPCSTR
    ctypes.c_void_p,  # AliasInterfaceGuid : GUID*
    wintypes.LPSTR,  # pszAliasDeviceInterface : LPSTR out
    ctypes.POINTER(wintypes.DWORD),  # pulLength : DWORD* in/out
    wintypes.DWORD,  # ulFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Get_Device_Interface_AliasA = Fiddle::Function.new(
  lib['CM_Get_Device_Interface_AliasA'],
  [
    Fiddle::TYPE_VOIDP,  # pszDeviceInterface : LPCSTR
    Fiddle::TYPE_VOIDP,  # AliasInterfaceGuid : GUID*
    Fiddle::TYPE_VOIDP,  # pszAliasDeviceInterface : LPSTR out
    Fiddle::TYPE_VOIDP,  # pulLength : DWORD* in/out
    -Fiddle::TYPE_INT,  # ulFlags : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "cfgmgr32")]
extern "system" {
    fn CM_Get_Device_Interface_AliasA(
        pszDeviceInterface: *const u8,  // LPCSTR
        AliasInterfaceGuid: *mut GUID,  // GUID*
        pszAliasDeviceInterface: *mut u8,  // LPSTR out
        pulLength: *mut u32,  // DWORD* in/out
        ulFlags: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CFGMGR32.dll", CharSet = CharSet.Ansi)]
public static extern uint CM_Get_Device_Interface_AliasA([MarshalAs(UnmanagedType.LPStr)] string pszDeviceInterface, ref Guid AliasInterfaceGuid, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszAliasDeviceInterface, ref uint pulLength, uint ulFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Get_Device_Interface_AliasA' -Namespace Win32 -PassThru
# $api::CM_Get_Device_Interface_AliasA(pszDeviceInterface, AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, ulFlags)
#uselib "CFGMGR32.dll"
#func global CM_Get_Device_Interface_AliasA "CM_Get_Device_Interface_AliasA" sptr, sptr, sptr, sptr, sptr
; CM_Get_Device_Interface_AliasA pszDeviceInterface, varptr(AliasInterfaceGuid), varptr(pszAliasDeviceInterface), varptr(pulLength), ulFlags   ; 戻り値は stat
; pszDeviceInterface : LPCSTR -> "sptr"
; AliasInterfaceGuid : GUID* -> "sptr"
; pszAliasDeviceInterface : LPSTR out -> "sptr"
; pulLength : DWORD* in/out -> "sptr"
; ulFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_Device_Interface_AliasA "CM_Get_Device_Interface_AliasA" str, var, var, var, int
; res = CM_Get_Device_Interface_AliasA(pszDeviceInterface, AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, ulFlags)
; pszDeviceInterface : LPCSTR -> "str"
; AliasInterfaceGuid : GUID* -> "var"
; pszAliasDeviceInterface : LPSTR out -> "var"
; pulLength : DWORD* in/out -> "var"
; ulFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; CONFIGRET CM_Get_Device_Interface_AliasA(LPCSTR pszDeviceInterface, GUID* AliasInterfaceGuid, LPSTR pszAliasDeviceInterface, DWORD* pulLength, DWORD ulFlags)
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_Device_Interface_AliasA "CM_Get_Device_Interface_AliasA" str, var, var, var, int
; res = CM_Get_Device_Interface_AliasA(pszDeviceInterface, AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, ulFlags)
; pszDeviceInterface : LPCSTR -> "str"
; AliasInterfaceGuid : GUID* -> "var"
; pszAliasDeviceInterface : LPSTR out -> "var"
; pulLength : 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_AliasA = cfgmgr32.NewProc("CM_Get_Device_Interface_AliasA")
)

// pszDeviceInterface (LPCSTR), AliasInterfaceGuid (GUID*), pszAliasDeviceInterface (LPSTR out), pulLength (DWORD* in/out), ulFlags (DWORD)
r1, _, err := procCM_Get_Device_Interface_AliasA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pszDeviceInterface))),
	uintptr(AliasInterfaceGuid),
	uintptr(pszAliasDeviceInterface),
	uintptr(pulLength),
	uintptr(ulFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CONFIGRET
function CM_Get_Device_Interface_AliasA(
  pszDeviceInterface: PAnsiChar;   // LPCSTR
  AliasInterfaceGuid: PGUID;   // GUID*
  pszAliasDeviceInterface: PAnsiChar;   // LPSTR out
  pulLength: Pointer;   // DWORD* in/out
  ulFlags: DWORD   // DWORD
): DWORD; stdcall;
  external 'CFGMGR32.dll' name 'CM_Get_Device_Interface_AliasA';
result := DllCall("CFGMGR32\CM_Get_Device_Interface_AliasA"
    , "AStr", pszDeviceInterface   ; LPCSTR
    , "Ptr", AliasInterfaceGuid   ; GUID*
    , "Ptr", pszAliasDeviceInterface   ; LPSTR out
    , "Ptr", pulLength   ; DWORD* in/out
    , "UInt", ulFlags   ; DWORD
    , "UInt")   ; return: CONFIGRET
●CM_Get_Device_Interface_AliasA(pszDeviceInterface, AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, ulFlags) = DLL("CFGMGR32.dll", "dword CM_Get_Device_Interface_AliasA(char*, void*, char*, void*, dword)")
# 呼び出し: CM_Get_Device_Interface_AliasA(pszDeviceInterface, AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, ulFlags)
# pszDeviceInterface : LPCSTR -> "char*"
# AliasInterfaceGuid : GUID* -> "void*"
# pszAliasDeviceInterface : LPSTR out -> "char*"
# pulLength : DWORD* in/out -> "void*"
# ulFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。