ホーム › Devices.DeviceAndDriverInstallation › CM_Unregister_Device_InterfaceW
CM_Unregister_Device_InterfaceW
関数デバイスインターフェイスのインスタンスを登録解除する。
シグネチャ
// CFGMGR32.dll (Unicode / -W)
#include <windows.h>
CONFIGRET CM_Unregister_Device_InterfaceW(
LPCWSTR pszDeviceInterface,
DWORD ulFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszDeviceInterface | LPCWSTR | in |
| ulFlags | DWORD | in |
戻り値の型: CONFIGRET
各言語での呼び出し定義
// CFGMGR32.dll (Unicode / -W)
#include <windows.h>
CONFIGRET CM_Unregister_Device_InterfaceW(
LPCWSTR pszDeviceInterface,
DWORD ulFlags
);[DllImport("CFGMGR32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint CM_Unregister_Device_InterfaceW(
[MarshalAs(UnmanagedType.LPWStr)] string pszDeviceInterface, // LPCWSTR
uint ulFlags // DWORD
);<DllImport("CFGMGR32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CM_Unregister_Device_InterfaceW(
<MarshalAs(UnmanagedType.LPWStr)> pszDeviceInterface As String, ' LPCWSTR
ulFlags As UInteger ' DWORD
) As UInteger
End Function' pszDeviceInterface : LPCWSTR
' ulFlags : DWORD
Declare PtrSafe Function CM_Unregister_Device_InterfaceW Lib "cfgmgr32" ( _
ByVal pszDeviceInterface As LongPtr, _
ByVal ulFlags As Long) 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
CM_Unregister_Device_InterfaceW = ctypes.windll.cfgmgr32.CM_Unregister_Device_InterfaceW
CM_Unregister_Device_InterfaceW.restype = wintypes.DWORD
CM_Unregister_Device_InterfaceW.argtypes = [
wintypes.LPCWSTR, # pszDeviceInterface : LPCWSTR
wintypes.DWORD, # ulFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Unregister_Device_InterfaceW = Fiddle::Function.new(
lib['CM_Unregister_Device_InterfaceW'],
[
Fiddle::TYPE_VOIDP, # pszDeviceInterface : LPCWSTR
-Fiddle::TYPE_INT, # ulFlags : DWORD
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "cfgmgr32")]
extern "system" {
fn CM_Unregister_Device_InterfaceW(
pszDeviceInterface: *const u16, // LPCWSTR
ulFlags: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CFGMGR32.dll", CharSet = CharSet.Unicode)]
public static extern uint CM_Unregister_Device_InterfaceW([MarshalAs(UnmanagedType.LPWStr)] string pszDeviceInterface, uint ulFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Unregister_Device_InterfaceW' -Namespace Win32 -PassThru
# $api::CM_Unregister_Device_InterfaceW(pszDeviceInterface, ulFlags)#uselib "CFGMGR32.dll"
#func global CM_Unregister_Device_InterfaceW "CM_Unregister_Device_InterfaceW" wptr, wptr
; CM_Unregister_Device_InterfaceW pszDeviceInterface, ulFlags ; 戻り値は stat
; pszDeviceInterface : LPCWSTR -> "wptr"
; ulFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CFGMGR32.dll"
#cfunc global CM_Unregister_Device_InterfaceW "CM_Unregister_Device_InterfaceW" wstr, int
; res = CM_Unregister_Device_InterfaceW(pszDeviceInterface, ulFlags)
; pszDeviceInterface : LPCWSTR -> "wstr"
; ulFlags : DWORD -> "int"; CONFIGRET CM_Unregister_Device_InterfaceW(LPCWSTR pszDeviceInterface, DWORD ulFlags)
#uselib "CFGMGR32.dll"
#cfunc global CM_Unregister_Device_InterfaceW "CM_Unregister_Device_InterfaceW" wstr, int
; res = CM_Unregister_Device_InterfaceW(pszDeviceInterface, ulFlags)
; pszDeviceInterface : LPCWSTR -> "wstr"
; ulFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
procCM_Unregister_Device_InterfaceW = cfgmgr32.NewProc("CM_Unregister_Device_InterfaceW")
)
// pszDeviceInterface (LPCWSTR), ulFlags (DWORD)
r1, _, err := procCM_Unregister_Device_InterfaceW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDeviceInterface))),
uintptr(ulFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // CONFIGRETfunction CM_Unregister_Device_InterfaceW(
pszDeviceInterface: PWideChar; // LPCWSTR
ulFlags: DWORD // DWORD
): DWORD; stdcall;
external 'CFGMGR32.dll' name 'CM_Unregister_Device_InterfaceW';result := DllCall("CFGMGR32\CM_Unregister_Device_InterfaceW"
, "WStr", pszDeviceInterface ; LPCWSTR
, "UInt", ulFlags ; DWORD
, "UInt") ; return: CONFIGRET●CM_Unregister_Device_InterfaceW(pszDeviceInterface, ulFlags) = DLL("CFGMGR32.dll", "dword CM_Unregister_Device_InterfaceW(char*, dword)")
# 呼び出し: CM_Unregister_Device_InterfaceW(pszDeviceInterface, ulFlags)
# pszDeviceInterface : LPCWSTR -> "char*"
# ulFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。