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

InstallHinfSectionW

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

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

void InstallHinfSectionW(
    HWND Window,
    HINSTANCE ModuleHandle,
    LPCWSTR CommandLine,
    INT ShowCommand
);

パラメーター

名前方向
WindowHWNDin
ModuleHandleHINSTANCEin
CommandLineLPCWSTRin
ShowCommandINTin

戻り値の型: void

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

void InstallHinfSectionW(
    HWND Window,
    HINSTANCE ModuleHandle,
    LPCWSTR CommandLine,
    INT ShowCommand
);
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern void InstallHinfSectionW(
    IntPtr Window,   // HWND
    IntPtr ModuleHandle,   // HINSTANCE
    [MarshalAs(UnmanagedType.LPWStr)] string CommandLine,   // LPCWSTR
    int ShowCommand   // INT
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Sub InstallHinfSectionW(
    Window As IntPtr,   ' HWND
    ModuleHandle As IntPtr,   ' HINSTANCE
    <MarshalAs(UnmanagedType.LPWStr)> CommandLine As String,   ' LPCWSTR
    ShowCommand As Integer   ' INT
)
End Sub
' Window : HWND
' ModuleHandle : HINSTANCE
' CommandLine : LPCWSTR
' ShowCommand : INT
Declare PtrSafe Sub InstallHinfSectionW Lib "setupapi" ( _
    ByVal Window As LongPtr, _
    ByVal ModuleHandle As LongPtr, _
    ByVal CommandLine As LongPtr, _
    ByVal ShowCommand 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

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

lib = Fiddle.dlopen('SETUPAPI.dll')
InstallHinfSectionW = Fiddle::Function.new(
  lib['InstallHinfSectionW'],
  [
    Fiddle::TYPE_VOIDP,  # Window : HWND
    Fiddle::TYPE_VOIDP,  # ModuleHandle : HINSTANCE
    Fiddle::TYPE_VOIDP,  # CommandLine : LPCWSTR
    Fiddle::TYPE_INT,  # ShowCommand : INT
  ],
  Fiddle::TYPE_VOID)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn InstallHinfSectionW(
        Window: *mut core::ffi::c_void,  // HWND
        ModuleHandle: *mut core::ffi::c_void,  // HINSTANCE
        CommandLine: *const u16,  // LPCWSTR
        ShowCommand: i32  // INT
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode)]
public static extern void InstallHinfSectionW(IntPtr Window, IntPtr ModuleHandle, [MarshalAs(UnmanagedType.LPWStr)] string CommandLine, int ShowCommand);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_InstallHinfSectionW' -Namespace Win32 -PassThru
# $api::InstallHinfSectionW(Window, ModuleHandle, CommandLine, ShowCommand)
#uselib "SETUPAPI.dll"
#func global InstallHinfSectionW "InstallHinfSectionW" wptr, wptr, wptr, wptr
; InstallHinfSectionW Window, ModuleHandle, CommandLine, ShowCommand
; Window : HWND -> "wptr"
; ModuleHandle : HINSTANCE -> "wptr"
; CommandLine : LPCWSTR -> "wptr"
; ShowCommand : INT -> "wptr"
#uselib "SETUPAPI.dll"
#func global InstallHinfSectionW "InstallHinfSectionW" sptr, sptr, wstr, int
; InstallHinfSectionW Window, ModuleHandle, CommandLine, ShowCommand
; Window : HWND -> "sptr"
; ModuleHandle : HINSTANCE -> "sptr"
; CommandLine : LPCWSTR -> "wstr"
; ShowCommand : INT -> "int"
; void InstallHinfSectionW(HWND Window, HINSTANCE ModuleHandle, LPCWSTR CommandLine, INT ShowCommand)
#uselib "SETUPAPI.dll"
#func global InstallHinfSectionW "InstallHinfSectionW" intptr, intptr, wstr, int
; InstallHinfSectionW Window, ModuleHandle, CommandLine, ShowCommand
; Window : HWND -> "intptr"
; ModuleHandle : HINSTANCE -> "intptr"
; CommandLine : LPCWSTR -> "wstr"
; ShowCommand : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procInstallHinfSectionW = setupapi.NewProc("InstallHinfSectionW")
)

// Window (HWND), ModuleHandle (HINSTANCE), CommandLine (LPCWSTR), ShowCommand (INT)
r1, _, err := procInstallHinfSectionW.Call(
	uintptr(Window),
	uintptr(ModuleHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(CommandLine))),
	uintptr(ShowCommand),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure InstallHinfSectionW(
  Window: THandle;   // HWND
  ModuleHandle: THandle;   // HINSTANCE
  CommandLine: PWideChar;   // LPCWSTR
  ShowCommand: Integer   // INT
); stdcall;
  external 'SETUPAPI.dll' name 'InstallHinfSectionW';
result := DllCall("SETUPAPI\InstallHinfSectionW"
    , "Ptr", Window   ; HWND
    , "Ptr", ModuleHandle   ; HINSTANCE
    , "WStr", CommandLine   ; LPCWSTR
    , "Int", ShowCommand   ; INT
    , "Int")   ; return: void
●InstallHinfSectionW(Window, ModuleHandle, CommandLine, ShowCommand) = DLL("SETUPAPI.dll", "int InstallHinfSectionW(void*, void*, char*, int)")
# 呼び出し: InstallHinfSectionW(Window, ModuleHandle, CommandLine, ShowCommand)
# Window : HWND -> "void*"
# ModuleHandle : HINSTANCE -> "void*"
# CommandLine : LPCWSTR -> "char*"
# ShowCommand : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。