ホーム › System.Com › CoRegisterDeviceCatalog
CoRegisterDeviceCatalog
関数デバイス用のCOMカタログを登録する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT CoRegisterDeviceCatalog(
LPCWSTR deviceInstanceId,
CO_DEVICE_CATALOG_COOKIE* cookie
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| deviceInstanceId | LPCWSTR | in |
| cookie | CO_DEVICE_CATALOG_COOKIE* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT CoRegisterDeviceCatalog(
LPCWSTR deviceInstanceId,
CO_DEVICE_CATALOG_COOKIE* cookie
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoRegisterDeviceCatalog(
[MarshalAs(UnmanagedType.LPWStr)] string deviceInstanceId, // LPCWSTR
IntPtr cookie // CO_DEVICE_CATALOG_COOKIE* out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoRegisterDeviceCatalog(
<MarshalAs(UnmanagedType.LPWStr)> deviceInstanceId As String, ' LPCWSTR
cookie As IntPtr ' CO_DEVICE_CATALOG_COOKIE* out
) As Integer
End Function' deviceInstanceId : LPCWSTR
' cookie : CO_DEVICE_CATALOG_COOKIE* out
Declare PtrSafe Function CoRegisterDeviceCatalog Lib "ole32" ( _
ByVal deviceInstanceId As LongPtr, _
ByVal cookie As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CoRegisterDeviceCatalog = ctypes.windll.ole32.CoRegisterDeviceCatalog
CoRegisterDeviceCatalog.restype = ctypes.c_int
CoRegisterDeviceCatalog.argtypes = [
wintypes.LPCWSTR, # deviceInstanceId : LPCWSTR
ctypes.c_void_p, # cookie : CO_DEVICE_CATALOG_COOKIE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
CoRegisterDeviceCatalog = Fiddle::Function.new(
lib['CoRegisterDeviceCatalog'],
[
Fiddle::TYPE_VOIDP, # deviceInstanceId : LPCWSTR
Fiddle::TYPE_VOIDP, # cookie : CO_DEVICE_CATALOG_COOKIE* out
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn CoRegisterDeviceCatalog(
deviceInstanceId: *const u16, // LPCWSTR
cookie: *mut *mut core::ffi::c_void // CO_DEVICE_CATALOG_COOKIE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int CoRegisterDeviceCatalog([MarshalAs(UnmanagedType.LPWStr)] string deviceInstanceId, IntPtr cookie);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CoRegisterDeviceCatalog' -Namespace Win32 -PassThru
# $api::CoRegisterDeviceCatalog(deviceInstanceId, cookie)#uselib "OLE32.dll"
#func global CoRegisterDeviceCatalog "CoRegisterDeviceCatalog" sptr, sptr
; CoRegisterDeviceCatalog deviceInstanceId, cookie ; 戻り値は stat
; deviceInstanceId : LPCWSTR -> "sptr"
; cookie : CO_DEVICE_CATALOG_COOKIE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global CoRegisterDeviceCatalog "CoRegisterDeviceCatalog" wstr, sptr
; res = CoRegisterDeviceCatalog(deviceInstanceId, cookie)
; deviceInstanceId : LPCWSTR -> "wstr"
; cookie : CO_DEVICE_CATALOG_COOKIE* out -> "sptr"; HRESULT CoRegisterDeviceCatalog(LPCWSTR deviceInstanceId, CO_DEVICE_CATALOG_COOKIE* cookie)
#uselib "OLE32.dll"
#cfunc global CoRegisterDeviceCatalog "CoRegisterDeviceCatalog" wstr, intptr
; res = CoRegisterDeviceCatalog(deviceInstanceId, cookie)
; deviceInstanceId : LPCWSTR -> "wstr"
; cookie : CO_DEVICE_CATALOG_COOKIE* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procCoRegisterDeviceCatalog = ole32.NewProc("CoRegisterDeviceCatalog")
)
// deviceInstanceId (LPCWSTR), cookie (CO_DEVICE_CATALOG_COOKIE* out)
r1, _, err := procCoRegisterDeviceCatalog.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(deviceInstanceId))),
uintptr(cookie),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CoRegisterDeviceCatalog(
deviceInstanceId: PWideChar; // LPCWSTR
cookie: Pointer // CO_DEVICE_CATALOG_COOKIE* out
): Integer; stdcall;
external 'OLE32.dll' name 'CoRegisterDeviceCatalog';result := DllCall("OLE32\CoRegisterDeviceCatalog"
, "WStr", deviceInstanceId ; LPCWSTR
, "Ptr", cookie ; CO_DEVICE_CATALOG_COOKIE* out
, "Int") ; return: HRESULT●CoRegisterDeviceCatalog(deviceInstanceId, cookie) = DLL("OLE32.dll", "int CoRegisterDeviceCatalog(char*, void*)")
# 呼び出し: CoRegisterDeviceCatalog(deviceInstanceId, cookie)
# deviceInstanceId : LPCWSTR -> "char*"
# cookie : CO_DEVICE_CATALOG_COOKIE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。