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