ホーム › Devices.DeviceAndDriverInstallation › SetupDiInstallClassA
SetupDiInstallClassA
関数INFファイルからデバイスセットアップクラスをインストールする。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupDiInstallClassA(
HWND hwndParent, // optional
LPCSTR InfFileName,
DWORD Flags,
void* FileQueue // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | inoptional |
| InfFileName | LPCSTR | in |
| Flags | DWORD | in |
| FileQueue | void* | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupDiInstallClassA(
HWND hwndParent, // optional
LPCSTR InfFileName,
DWORD Flags,
void* FileQueue // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupDiInstallClassA(
IntPtr hwndParent, // HWND optional
[MarshalAs(UnmanagedType.LPStr)] string InfFileName, // LPCSTR
uint Flags, // DWORD
IntPtr FileQueue // void* optional
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDiInstallClassA(
hwndParent As IntPtr, ' HWND optional
<MarshalAs(UnmanagedType.LPStr)> InfFileName As String, ' LPCSTR
Flags As UInteger, ' DWORD
FileQueue As IntPtr ' void* optional
) As Boolean
End Function' hwndParent : HWND optional
' InfFileName : LPCSTR
' Flags : DWORD
' FileQueue : void* optional
Declare PtrSafe Function SetupDiInstallClassA Lib "setupapi" ( _
ByVal hwndParent As LongPtr, _
ByVal InfFileName As String, _
ByVal Flags As Long, _
ByVal FileQueue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupDiInstallClassA = ctypes.windll.setupapi.SetupDiInstallClassA
SetupDiInstallClassA.restype = wintypes.BOOL
SetupDiInstallClassA.argtypes = [
wintypes.HANDLE, # hwndParent : HWND optional
wintypes.LPCSTR, # InfFileName : LPCSTR
wintypes.DWORD, # Flags : DWORD
ctypes.POINTER(None), # FileQueue : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiInstallClassA = Fiddle::Function.new(
lib['SetupDiInstallClassA'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
Fiddle::TYPE_VOIDP, # InfFileName : LPCSTR
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # FileQueue : void* optional
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupDiInstallClassA(
hwndParent: *mut core::ffi::c_void, // HWND optional
InfFileName: *const u8, // LPCSTR
Flags: u32, // DWORD
FileQueue: *mut () // void* 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 SetupDiInstallClassA(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPStr)] string InfFileName, uint Flags, IntPtr FileQueue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiInstallClassA' -Namespace Win32 -PassThru
# $api::SetupDiInstallClassA(hwndParent, InfFileName, Flags, FileQueue)#uselib "SETUPAPI.dll"
#func global SetupDiInstallClassA "SetupDiInstallClassA" sptr, sptr, sptr, sptr
; SetupDiInstallClassA hwndParent, InfFileName, Flags, FileQueue ; 戻り値は stat
; hwndParent : HWND optional -> "sptr"
; InfFileName : LPCSTR -> "sptr"
; Flags : DWORD -> "sptr"
; FileQueue : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupDiInstallClassA "SetupDiInstallClassA" sptr, str, int, sptr
; res = SetupDiInstallClassA(hwndParent, InfFileName, Flags, FileQueue)
; hwndParent : HWND optional -> "sptr"
; InfFileName : LPCSTR -> "str"
; Flags : DWORD -> "int"
; FileQueue : void* optional -> "sptr"; BOOL SetupDiInstallClassA(HWND hwndParent, LPCSTR InfFileName, DWORD Flags, void* FileQueue)
#uselib "SETUPAPI.dll"
#cfunc global SetupDiInstallClassA "SetupDiInstallClassA" intptr, str, int, intptr
; res = SetupDiInstallClassA(hwndParent, InfFileName, Flags, FileQueue)
; hwndParent : HWND optional -> "intptr"
; InfFileName : LPCSTR -> "str"
; Flags : DWORD -> "int"
; FileQueue : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupDiInstallClassA = setupapi.NewProc("SetupDiInstallClassA")
)
// hwndParent (HWND optional), InfFileName (LPCSTR), Flags (DWORD), FileQueue (void* optional)
r1, _, err := procSetupDiInstallClassA.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.BytePtrFromString(InfFileName))),
uintptr(Flags),
uintptr(FileQueue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupDiInstallClassA(
hwndParent: THandle; // HWND optional
InfFileName: PAnsiChar; // LPCSTR
Flags: DWORD; // DWORD
FileQueue: Pointer // void* optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiInstallClassA';result := DllCall("SETUPAPI\SetupDiInstallClassA"
, "Ptr", hwndParent ; HWND optional
, "AStr", InfFileName ; LPCSTR
, "UInt", Flags ; DWORD
, "Ptr", FileQueue ; void* optional
, "Int") ; return: BOOL●SetupDiInstallClassA(hwndParent, InfFileName, Flags, FileQueue) = DLL("SETUPAPI.dll", "bool SetupDiInstallClassA(void*, char*, dword, void*)")
# 呼び出し: SetupDiInstallClassA(hwndParent, InfFileName, Flags, FileQueue)
# hwndParent : HWND optional -> "void*"
# InfFileName : LPCSTR -> "char*"
# Flags : DWORD -> "dword"
# FileQueue : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。