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