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

InstallHinfSectionA

関数
rundll32経由でINFセクションを実行するインストールエントリ。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

void InstallHinfSectionA(
    HWND Window,
    HINSTANCE ModuleHandle,
    LPCSTR CommandLine,
    INT ShowCommand
);

パラメーター

名前方向
WindowHWNDin
ModuleHandleHINSTANCEin
CommandLineLPCSTRin
ShowCommandINTin

戻り値の型: void

各言語での呼び出し定義

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

void InstallHinfSectionA(
    HWND Window,
    HINSTANCE ModuleHandle,
    LPCSTR CommandLine,
    INT ShowCommand
);
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern void InstallHinfSectionA(
    IntPtr Window,   // HWND
    IntPtr ModuleHandle,   // HINSTANCE
    [MarshalAs(UnmanagedType.LPStr)] string CommandLine,   // LPCSTR
    int ShowCommand   // INT
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Sub InstallHinfSectionA(
    Window As IntPtr,   ' HWND
    ModuleHandle As IntPtr,   ' HINSTANCE
    <MarshalAs(UnmanagedType.LPStr)> CommandLine As String,   ' LPCSTR
    ShowCommand As Integer   ' INT
)
End Sub
' Window : HWND
' ModuleHandle : HINSTANCE
' CommandLine : LPCSTR
' ShowCommand : INT
Declare PtrSafe Sub InstallHinfSectionA Lib "setupapi" ( _
    ByVal Window As LongPtr, _
    ByVal ModuleHandle As LongPtr, _
    ByVal CommandLine As String, _
    ByVal ShowCommand As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

InstallHinfSectionA = ctypes.windll.setupapi.InstallHinfSectionA
InstallHinfSectionA.restype = None
InstallHinfSectionA.argtypes = [
    wintypes.HANDLE,  # Window : HWND
    wintypes.HANDLE,  # ModuleHandle : HINSTANCE
    wintypes.LPCSTR,  # CommandLine : LPCSTR
    ctypes.c_int,  # ShowCommand : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
InstallHinfSectionA = Fiddle::Function.new(
  lib['InstallHinfSectionA'],
  [
    Fiddle::TYPE_VOIDP,  # Window : HWND
    Fiddle::TYPE_VOIDP,  # ModuleHandle : HINSTANCE
    Fiddle::TYPE_VOIDP,  # CommandLine : LPCSTR
    Fiddle::TYPE_INT,  # ShowCommand : INT
  ],
  Fiddle::TYPE_VOID)
#[link(name = "setupapi")]
extern "system" {
    fn InstallHinfSectionA(
        Window: *mut core::ffi::c_void,  // HWND
        ModuleHandle: *mut core::ffi::c_void,  // HINSTANCE
        CommandLine: *const u8,  // LPCSTR
        ShowCommand: i32  // INT
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi)]
public static extern void InstallHinfSectionA(IntPtr Window, IntPtr ModuleHandle, [MarshalAs(UnmanagedType.LPStr)] string CommandLine, int ShowCommand);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_InstallHinfSectionA' -Namespace Win32 -PassThru
# $api::InstallHinfSectionA(Window, ModuleHandle, CommandLine, ShowCommand)
#uselib "SETUPAPI.dll"
#func global InstallHinfSectionA "InstallHinfSectionA" sptr, sptr, sptr, sptr
; InstallHinfSectionA Window, ModuleHandle, CommandLine, ShowCommand
; Window : HWND -> "sptr"
; ModuleHandle : HINSTANCE -> "sptr"
; CommandLine : LPCSTR -> "sptr"
; ShowCommand : INT -> "sptr"
#uselib "SETUPAPI.dll"
#func global InstallHinfSectionA "InstallHinfSectionA" sptr, sptr, str, int
; InstallHinfSectionA Window, ModuleHandle, CommandLine, ShowCommand
; Window : HWND -> "sptr"
; ModuleHandle : HINSTANCE -> "sptr"
; CommandLine : LPCSTR -> "str"
; ShowCommand : INT -> "int"
; void InstallHinfSectionA(HWND Window, HINSTANCE ModuleHandle, LPCSTR CommandLine, INT ShowCommand)
#uselib "SETUPAPI.dll"
#func global InstallHinfSectionA "InstallHinfSectionA" intptr, intptr, str, int
; InstallHinfSectionA Window, ModuleHandle, CommandLine, ShowCommand
; Window : HWND -> "intptr"
; ModuleHandle : HINSTANCE -> "intptr"
; CommandLine : LPCSTR -> "str"
; ShowCommand : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procInstallHinfSectionA = setupapi.NewProc("InstallHinfSectionA")
)

// Window (HWND), ModuleHandle (HINSTANCE), CommandLine (LPCSTR), ShowCommand (INT)
r1, _, err := procInstallHinfSectionA.Call(
	uintptr(Window),
	uintptr(ModuleHandle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(CommandLine))),
	uintptr(ShowCommand),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure InstallHinfSectionA(
  Window: THandle;   // HWND
  ModuleHandle: THandle;   // HINSTANCE
  CommandLine: PAnsiChar;   // LPCSTR
  ShowCommand: Integer   // INT
); stdcall;
  external 'SETUPAPI.dll' name 'InstallHinfSectionA';
result := DllCall("SETUPAPI\InstallHinfSectionA"
    , "Ptr", Window   ; HWND
    , "Ptr", ModuleHandle   ; HINSTANCE
    , "AStr", CommandLine   ; LPCSTR
    , "Int", ShowCommand   ; INT
    , "Int")   ; return: void
●InstallHinfSectionA(Window, ModuleHandle, CommandLine, ShowCommand) = DLL("SETUPAPI.dll", "int InstallHinfSectionA(void*, void*, char*, int)")
# 呼び出し: InstallHinfSectionA(Window, ModuleHandle, CommandLine, ShowCommand)
# Window : HWND -> "void*"
# ModuleHandle : HINSTANCE -> "void*"
# CommandLine : LPCSTR -> "char*"
# ShowCommand : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。