Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupSetDirectoryIdA

SetupSetDirectoryIdA

関数
INFのディレクトリ識別子に実際のパスを関連付ける(ANSI)。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL SetupSetDirectoryIdA(
    void* InfHandle,
    DWORD Id,
    LPCSTR Directory   // optional
);

パラメーター

名前方向
InfHandlevoid*in
IdDWORDin
DirectoryLPCSTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL SetupSetDirectoryIdA(
    void* InfHandle,
    DWORD Id,
    LPCSTR Directory   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupSetDirectoryIdA(
    IntPtr InfHandle,   // void*
    uint Id,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string Directory   // LPCSTR optional
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupSetDirectoryIdA(
    InfHandle As IntPtr,   ' void*
    Id As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> Directory As String   ' LPCSTR optional
) As Boolean
End Function
' InfHandle : void*
' Id : DWORD
' Directory : LPCSTR optional
Declare PtrSafe Function SetupSetDirectoryIdA Lib "setupapi" ( _
    ByVal InfHandle As LongPtr, _
    ByVal Id As Long, _
    ByVal Directory As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupSetDirectoryIdA = ctypes.windll.setupapi.SetupSetDirectoryIdA
SetupSetDirectoryIdA.restype = wintypes.BOOL
SetupSetDirectoryIdA.argtypes = [
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.DWORD,  # Id : DWORD
    wintypes.LPCSTR,  # Directory : LPCSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupSetDirectoryIdA = Fiddle::Function.new(
  lib['SetupSetDirectoryIdA'],
  [
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    -Fiddle::TYPE_INT,  # Id : DWORD
    Fiddle::TYPE_VOIDP,  # Directory : LPCSTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupSetDirectoryIdA(
        InfHandle: *mut (),  // void*
        Id: u32,  // DWORD
        Directory: *const u8  // LPCSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool SetupSetDirectoryIdA(IntPtr InfHandle, uint Id, [MarshalAs(UnmanagedType.LPStr)] string Directory);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupSetDirectoryIdA' -Namespace Win32 -PassThru
# $api::SetupSetDirectoryIdA(InfHandle, Id, Directory)
#uselib "SETUPAPI.dll"
#func global SetupSetDirectoryIdA "SetupSetDirectoryIdA" sptr, sptr, sptr
; SetupSetDirectoryIdA InfHandle, Id, Directory   ; 戻り値は stat
; InfHandle : void* -> "sptr"
; Id : DWORD -> "sptr"
; Directory : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupSetDirectoryIdA "SetupSetDirectoryIdA" sptr, int, str
; res = SetupSetDirectoryIdA(InfHandle, Id, Directory)
; InfHandle : void* -> "sptr"
; Id : DWORD -> "int"
; Directory : LPCSTR optional -> "str"
; BOOL SetupSetDirectoryIdA(void* InfHandle, DWORD Id, LPCSTR Directory)
#uselib "SETUPAPI.dll"
#cfunc global SetupSetDirectoryIdA "SetupSetDirectoryIdA" intptr, int, str
; res = SetupSetDirectoryIdA(InfHandle, Id, Directory)
; InfHandle : void* -> "intptr"
; Id : DWORD -> "int"
; Directory : LPCSTR optional -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupSetDirectoryIdA = setupapi.NewProc("SetupSetDirectoryIdA")
)

// InfHandle (void*), Id (DWORD), Directory (LPCSTR optional)
r1, _, err := procSetupSetDirectoryIdA.Call(
	uintptr(InfHandle),
	uintptr(Id),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Directory))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupSetDirectoryIdA(
  InfHandle: Pointer;   // void*
  Id: DWORD;   // DWORD
  Directory: PAnsiChar   // LPCSTR optional
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupSetDirectoryIdA';
result := DllCall("SETUPAPI\SetupSetDirectoryIdA"
    , "Ptr", InfHandle   ; void*
    , "UInt", Id   ; DWORD
    , "AStr", Directory   ; LPCSTR optional
    , "Int")   ; return: BOOL
●SetupSetDirectoryIdA(InfHandle, Id, Directory) = DLL("SETUPAPI.dll", "bool SetupSetDirectoryIdA(void*, dword, char*)")
# 呼び出し: SetupSetDirectoryIdA(InfHandle, Id, Directory)
# InfHandle : void* -> "void*"
# Id : DWORD -> "dword"
# Directory : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。