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

SetupInstallServicesFromInfSectionExA

関数
デバイス情報を指定しINFセクションのサービスをインストールする。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupInstallServicesFromInfSectionExA(
    void* InfHandle,
    LPCSTR SectionName,
    SPSVCINST_FLAGS Flags,
    HDEVINFO DeviceInfoSet,   // optional
    SP_DEVINFO_DATA* DeviceInfoData,   // optional
    void* Reserved1,   // optional
    void* Reserved2   // optional
);

パラメーター

名前方向
InfHandlevoid*in
SectionNameLPCSTRin
FlagsSPSVCINST_FLAGSin
DeviceInfoSetHDEVINFOinoptional
DeviceInfoDataSP_DEVINFO_DATA*inoptional
Reserved1void*optional
Reserved2void*optional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupInstallServicesFromInfSectionExA = ctypes.windll.setupapi.SetupInstallServicesFromInfSectionExA
SetupInstallServicesFromInfSectionExA.restype = wintypes.BOOL
SetupInstallServicesFromInfSectionExA.argtypes = [
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.LPCSTR,  # SectionName : LPCSTR
    wintypes.DWORD,  # Flags : SPSVCINST_FLAGS
    ctypes.c_ssize_t,  # DeviceInfoSet : HDEVINFO optional
    ctypes.c_void_p,  # DeviceInfoData : SP_DEVINFO_DATA* optional
    ctypes.POINTER(None),  # Reserved1 : void* 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')
SetupInstallServicesFromInfSectionExA = Fiddle::Function.new(
  lib['SetupInstallServicesFromInfSectionExA'],
  [
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # SectionName : LPCSTR
    -Fiddle::TYPE_INT,  # Flags : SPSVCINST_FLAGS
    Fiddle::TYPE_INTPTR_T,  # DeviceInfoSet : HDEVINFO optional
    Fiddle::TYPE_VOIDP,  # DeviceInfoData : SP_DEVINFO_DATA* optional
    Fiddle::TYPE_VOIDP,  # Reserved1 : void* optional
    Fiddle::TYPE_VOIDP,  # Reserved2 : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupInstallServicesFromInfSectionExA(
        InfHandle: *mut (),  // void*
        SectionName: *const u8,  // LPCSTR
        Flags: u32,  // SPSVCINST_FLAGS
        DeviceInfoSet: isize,  // HDEVINFO optional
        DeviceInfoData: *mut SP_DEVINFO_DATA,  // SP_DEVINFO_DATA* optional
        Reserved1: *mut (),  // void* 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.Ansi, SetLastError = true)]
public static extern bool SetupInstallServicesFromInfSectionExA(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string SectionName, uint Flags, IntPtr DeviceInfoSet, IntPtr DeviceInfoData, IntPtr Reserved1, IntPtr Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupInstallServicesFromInfSectionExA' -Namespace Win32 -PassThru
# $api::SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
#uselib "SETUPAPI.dll"
#func global SetupInstallServicesFromInfSectionExA "SetupInstallServicesFromInfSectionExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupInstallServicesFromInfSectionExA InfHandle, SectionName, Flags, DeviceInfoSet, varptr(DeviceInfoData), Reserved1, Reserved2   ; 戻り値は stat
; InfHandle : void* -> "sptr"
; SectionName : LPCSTR -> "sptr"
; Flags : SPSVCINST_FLAGS -> "sptr"
; DeviceInfoSet : HDEVINFO optional -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "sptr"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SETUPAPI.dll"
#cfunc global SetupInstallServicesFromInfSectionExA "SetupInstallServicesFromInfSectionExA" sptr, str, int, sptr, var, sptr, sptr
; res = SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
; InfHandle : void* -> "sptr"
; SectionName : LPCSTR -> "str"
; Flags : SPSVCINST_FLAGS -> "int"
; DeviceInfoSet : HDEVINFO optional -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetupInstallServicesFromInfSectionExA(void* InfHandle, LPCSTR SectionName, SPSVCINST_FLAGS Flags, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, void* Reserved1, void* Reserved2)
#uselib "SETUPAPI.dll"
#cfunc global SetupInstallServicesFromInfSectionExA "SetupInstallServicesFromInfSectionExA" intptr, str, int, intptr, var, intptr, intptr
; res = SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
; InfHandle : void* -> "intptr"
; SectionName : LPCSTR -> "str"
; Flags : SPSVCINST_FLAGS -> "int"
; DeviceInfoSet : HDEVINFO optional -> "intptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var"
; Reserved1 : void* optional -> "intptr"
; Reserved2 : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupInstallServicesFromInfSectionExA = setupapi.NewProc("SetupInstallServicesFromInfSectionExA")
)

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