ホーム › Devices.DeviceAndDriverInstallation › SetupSetDirectoryIdW
SetupSetDirectoryIdW
関数INFのディレクトリ識別子に実際のパスを関連付ける(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupSetDirectoryIdW(
void* InfHandle,
DWORD Id,
LPCWSTR Directory // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| InfHandle | void* | in |
| Id | DWORD | in |
| Directory | LPCWSTR | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupSetDirectoryIdW(
void* InfHandle,
DWORD Id,
LPCWSTR Directory // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupSetDirectoryIdW(
IntPtr InfHandle, // void*
uint Id, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string Directory // LPCWSTR optional
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupSetDirectoryIdW(
InfHandle As IntPtr, ' void*
Id As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> Directory As String ' LPCWSTR optional
) As Boolean
End Function' InfHandle : void*
' Id : DWORD
' Directory : LPCWSTR optional
Declare PtrSafe Function SetupSetDirectoryIdW Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal Id As Long, _
ByVal Directory As LongPtr) 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
SetupSetDirectoryIdW = ctypes.windll.setupapi.SetupSetDirectoryIdW
SetupSetDirectoryIdW.restype = wintypes.BOOL
SetupSetDirectoryIdW.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
wintypes.DWORD, # Id : DWORD
wintypes.LPCWSTR, # Directory : LPCWSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupSetDirectoryIdW = Fiddle::Function.new(
lib['SetupSetDirectoryIdW'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
-Fiddle::TYPE_INT, # Id : DWORD
Fiddle::TYPE_VOIDP, # Directory : LPCWSTR optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupSetDirectoryIdW(
InfHandle: *mut (), // void*
Id: u32, // DWORD
Directory: *const u16 // LPCWSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupSetDirectoryIdW(IntPtr InfHandle, uint Id, [MarshalAs(UnmanagedType.LPWStr)] string Directory);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupSetDirectoryIdW' -Namespace Win32 -PassThru
# $api::SetupSetDirectoryIdW(InfHandle, Id, Directory)#uselib "SETUPAPI.dll"
#func global SetupSetDirectoryIdW "SetupSetDirectoryIdW" wptr, wptr, wptr
; SetupSetDirectoryIdW InfHandle, Id, Directory ; 戻り値は stat
; InfHandle : void* -> "wptr"
; Id : DWORD -> "wptr"
; Directory : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupSetDirectoryIdW "SetupSetDirectoryIdW" sptr, int, wstr
; res = SetupSetDirectoryIdW(InfHandle, Id, Directory)
; InfHandle : void* -> "sptr"
; Id : DWORD -> "int"
; Directory : LPCWSTR optional -> "wstr"; BOOL SetupSetDirectoryIdW(void* InfHandle, DWORD Id, LPCWSTR Directory)
#uselib "SETUPAPI.dll"
#cfunc global SetupSetDirectoryIdW "SetupSetDirectoryIdW" intptr, int, wstr
; res = SetupSetDirectoryIdW(InfHandle, Id, Directory)
; InfHandle : void* -> "intptr"
; Id : DWORD -> "int"
; Directory : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupSetDirectoryIdW = setupapi.NewProc("SetupSetDirectoryIdW")
)
// InfHandle (void*), Id (DWORD), Directory (LPCWSTR optional)
r1, _, err := procSetupSetDirectoryIdW.Call(
uintptr(InfHandle),
uintptr(Id),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Directory))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupSetDirectoryIdW(
InfHandle: Pointer; // void*
Id: DWORD; // DWORD
Directory: PWideChar // LPCWSTR optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupSetDirectoryIdW';result := DllCall("SETUPAPI\SetupSetDirectoryIdW"
, "Ptr", InfHandle ; void*
, "UInt", Id ; DWORD
, "WStr", Directory ; LPCWSTR optional
, "Int") ; return: BOOL●SetupSetDirectoryIdW(InfHandle, Id, Directory) = DLL("SETUPAPI.dll", "bool SetupSetDirectoryIdW(void*, dword, char*)")
# 呼び出し: SetupSetDirectoryIdW(InfHandle, Id, Directory)
# InfHandle : void* -> "void*"
# Id : DWORD -> "dword"
# Directory : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。