ホーム › Devices.DeviceAndDriverInstallation › SetupInstallServicesFromInfSectionExW
SetupInstallServicesFromInfSectionExW
関数デバイス情報を指定しINFセクションのサービスをインストールする。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupInstallServicesFromInfSectionExW(
void* InfHandle,
LPCWSTR SectionName,
SPSVCINST_FLAGS Flags,
HDEVINFO DeviceInfoSet, // optional
SP_DEVINFO_DATA* DeviceInfoData, // optional
void* Reserved1, // optional
void* Reserved2 // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| InfHandle | void* | in |
| SectionName | LPCWSTR | in |
| Flags | SPSVCINST_FLAGS | in |
| DeviceInfoSet | HDEVINFO | inoptional |
| DeviceInfoData | SP_DEVINFO_DATA* | inoptional |
| Reserved1 | void* | optional |
| Reserved2 | void* | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupInstallServicesFromInfSectionExW(
void* InfHandle,
LPCWSTR 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.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupInstallServicesFromInfSectionExW(
IntPtr InfHandle, // void*
[MarshalAs(UnmanagedType.LPWStr)] string SectionName, // LPCWSTR
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.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupInstallServicesFromInfSectionExW(
InfHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> SectionName As String, ' LPCWSTR
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 : LPCWSTR
' Flags : SPSVCINST_FLAGS
' DeviceInfoSet : HDEVINFO optional
' DeviceInfoData : SP_DEVINFO_DATA* optional
' Reserved1 : void* optional
' Reserved2 : void* optional
Declare PtrSafe Function SetupInstallServicesFromInfSectionExW Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal SectionName As LongPtr, _
ByVal Flags As Long, _
ByVal DeviceInfoSet As LongPtr, _
ByVal DeviceInfoData As LongPtr, _
ByVal Reserved1 As LongPtr, _
ByVal Reserved2 As LongPtr) 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
SetupInstallServicesFromInfSectionExW = ctypes.windll.setupapi.SetupInstallServicesFromInfSectionExW
SetupInstallServicesFromInfSectionExW.restype = wintypes.BOOL
SetupInstallServicesFromInfSectionExW.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
wintypes.LPCWSTR, # SectionName : LPCWSTR
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')
SetupInstallServicesFromInfSectionExW = Fiddle::Function.new(
lib['SetupInstallServicesFromInfSectionExW'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # SectionName : LPCWSTR
-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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupInstallServicesFromInfSectionExW(
InfHandle: *mut (), // void*
SectionName: *const u16, // LPCWSTR
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.Unicode, SetLastError = true)]
public static extern bool SetupInstallServicesFromInfSectionExW(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPWStr)] string SectionName, uint Flags, IntPtr DeviceInfoSet, IntPtr DeviceInfoData, IntPtr Reserved1, IntPtr Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupInstallServicesFromInfSectionExW' -Namespace Win32 -PassThru
# $api::SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)#uselib "SETUPAPI.dll"
#func global SetupInstallServicesFromInfSectionExW "SetupInstallServicesFromInfSectionExW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupInstallServicesFromInfSectionExW InfHandle, SectionName, Flags, DeviceInfoSet, varptr(DeviceInfoData), Reserved1, Reserved2 ; 戻り値は stat
; InfHandle : void* -> "wptr"
; SectionName : LPCWSTR -> "wptr"
; Flags : SPSVCINST_FLAGS -> "wptr"
; DeviceInfoSet : HDEVINFO optional -> "wptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "wptr"
; Reserved1 : void* optional -> "wptr"
; Reserved2 : void* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupInstallServicesFromInfSectionExW "SetupInstallServicesFromInfSectionExW" sptr, wstr, int, sptr, var, sptr, sptr ; res = SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2) ; InfHandle : void* -> "sptr" ; SectionName : LPCWSTR -> "wstr" ; Flags : SPSVCINST_FLAGS -> "int" ; DeviceInfoSet : HDEVINFO optional -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var" ; Reserved1 : void* optional -> "sptr" ; Reserved2 : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupInstallServicesFromInfSectionExW "SetupInstallServicesFromInfSectionExW" sptr, wstr, int, sptr, sptr, sptr, sptr ; res = SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, varptr(DeviceInfoData), Reserved1, Reserved2) ; InfHandle : void* -> "sptr" ; SectionName : LPCWSTR -> "wstr" ; Flags : SPSVCINST_FLAGS -> "int" ; DeviceInfoSet : HDEVINFO optional -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "sptr" ; Reserved1 : void* optional -> "sptr" ; Reserved2 : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupInstallServicesFromInfSectionExW(void* InfHandle, LPCWSTR SectionName, SPSVCINST_FLAGS Flags, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, void* Reserved1, void* Reserved2) #uselib "SETUPAPI.dll" #cfunc global SetupInstallServicesFromInfSectionExW "SetupInstallServicesFromInfSectionExW" intptr, wstr, int, intptr, var, intptr, intptr ; res = SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2) ; InfHandle : void* -> "intptr" ; SectionName : LPCWSTR -> "wstr" ; Flags : SPSVCINST_FLAGS -> "int" ; DeviceInfoSet : HDEVINFO optional -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var" ; Reserved1 : void* optional -> "intptr" ; Reserved2 : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupInstallServicesFromInfSectionExW(void* InfHandle, LPCWSTR SectionName, SPSVCINST_FLAGS Flags, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, void* Reserved1, void* Reserved2) #uselib "SETUPAPI.dll" #cfunc global SetupInstallServicesFromInfSectionExW "SetupInstallServicesFromInfSectionExW" intptr, wstr, int, intptr, intptr, intptr, intptr ; res = SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, varptr(DeviceInfoData), Reserved1, Reserved2) ; InfHandle : void* -> "intptr" ; SectionName : LPCWSTR -> "wstr" ; Flags : SPSVCINST_FLAGS -> "int" ; DeviceInfoSet : HDEVINFO optional -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "intptr" ; Reserved1 : void* optional -> "intptr" ; Reserved2 : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupInstallServicesFromInfSectionExW = setupapi.NewProc("SetupInstallServicesFromInfSectionExW")
)
// InfHandle (void*), SectionName (LPCWSTR), Flags (SPSVCINST_FLAGS), DeviceInfoSet (HDEVINFO optional), DeviceInfoData (SP_DEVINFO_DATA* optional), Reserved1 (void* optional), Reserved2 (void* optional)
r1, _, err := procSetupInstallServicesFromInfSectionExW.Call(
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SectionName))),
uintptr(Flags),
uintptr(DeviceInfoSet),
uintptr(DeviceInfoData),
uintptr(Reserved1),
uintptr(Reserved2),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupInstallServicesFromInfSectionExW(
InfHandle: Pointer; // void*
SectionName: PWideChar; // LPCWSTR
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 'SetupInstallServicesFromInfSectionExW';result := DllCall("SETUPAPI\SetupInstallServicesFromInfSectionExW"
, "Ptr", InfHandle ; void*
, "WStr", SectionName ; LPCWSTR
, "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●SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2) = DLL("SETUPAPI.dll", "bool SetupInstallServicesFromInfSectionExW(void*, char*, dword, int, void*, void*, void*)")
# 呼び出し: SetupInstallServicesFromInfSectionExW(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
# InfHandle : void* -> "void*"
# SectionName : LPCWSTR -> "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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。