ホーム › Devices.DeviceAndDriverInstallation › SetupInstallServicesFromInfSectionW
SetupInstallServicesFromInfSectionW
関数INFセクションの指定に従いサービスをインストール設定する。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupInstallServicesFromInfSectionW(
void* InfHandle,
LPCWSTR SectionName,
SPSVCINST_FLAGS Flags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| InfHandle | void* | in |
| SectionName | LPCWSTR | in |
| Flags | SPSVCINST_FLAGS | in |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupInstallServicesFromInfSectionW(
void* InfHandle,
LPCWSTR SectionName,
SPSVCINST_FLAGS Flags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupInstallServicesFromInfSectionW(
IntPtr InfHandle, // void*
[MarshalAs(UnmanagedType.LPWStr)] string SectionName, // LPCWSTR
uint Flags // SPSVCINST_FLAGS
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupInstallServicesFromInfSectionW(
InfHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> SectionName As String, ' LPCWSTR
Flags As UInteger ' SPSVCINST_FLAGS
) As Boolean
End Function' InfHandle : void*
' SectionName : LPCWSTR
' Flags : SPSVCINST_FLAGS
Declare PtrSafe Function SetupInstallServicesFromInfSectionW Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal SectionName As LongPtr, _
ByVal Flags As Long) 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
SetupInstallServicesFromInfSectionW = ctypes.windll.setupapi.SetupInstallServicesFromInfSectionW
SetupInstallServicesFromInfSectionW.restype = wintypes.BOOL
SetupInstallServicesFromInfSectionW.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
wintypes.LPCWSTR, # SectionName : LPCWSTR
wintypes.DWORD, # Flags : SPSVCINST_FLAGS
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupInstallServicesFromInfSectionW = Fiddle::Function.new(
lib['SetupInstallServicesFromInfSectionW'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # SectionName : LPCWSTR
-Fiddle::TYPE_INT, # Flags : SPSVCINST_FLAGS
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupInstallServicesFromInfSectionW(
InfHandle: *mut (), // void*
SectionName: *const u16, // LPCWSTR
Flags: u32 // SPSVCINST_FLAGS
) -> 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 SetupInstallServicesFromInfSectionW(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPWStr)] string SectionName, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupInstallServicesFromInfSectionW' -Namespace Win32 -PassThru
# $api::SetupInstallServicesFromInfSectionW(InfHandle, SectionName, Flags)#uselib "SETUPAPI.dll"
#func global SetupInstallServicesFromInfSectionW "SetupInstallServicesFromInfSectionW" wptr, wptr, wptr
; SetupInstallServicesFromInfSectionW InfHandle, SectionName, Flags ; 戻り値は stat
; InfHandle : void* -> "wptr"
; SectionName : LPCWSTR -> "wptr"
; Flags : SPSVCINST_FLAGS -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupInstallServicesFromInfSectionW "SetupInstallServicesFromInfSectionW" sptr, wstr, int
; res = SetupInstallServicesFromInfSectionW(InfHandle, SectionName, Flags)
; InfHandle : void* -> "sptr"
; SectionName : LPCWSTR -> "wstr"
; Flags : SPSVCINST_FLAGS -> "int"; BOOL SetupInstallServicesFromInfSectionW(void* InfHandle, LPCWSTR SectionName, SPSVCINST_FLAGS Flags)
#uselib "SETUPAPI.dll"
#cfunc global SetupInstallServicesFromInfSectionW "SetupInstallServicesFromInfSectionW" intptr, wstr, int
; res = SetupInstallServicesFromInfSectionW(InfHandle, SectionName, Flags)
; InfHandle : void* -> "intptr"
; SectionName : LPCWSTR -> "wstr"
; Flags : SPSVCINST_FLAGS -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupInstallServicesFromInfSectionW = setupapi.NewProc("SetupInstallServicesFromInfSectionW")
)
// InfHandle (void*), SectionName (LPCWSTR), Flags (SPSVCINST_FLAGS)
r1, _, err := procSetupInstallServicesFromInfSectionW.Call(
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SectionName))),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupInstallServicesFromInfSectionW(
InfHandle: Pointer; // void*
SectionName: PWideChar; // LPCWSTR
Flags: DWORD // SPSVCINST_FLAGS
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupInstallServicesFromInfSectionW';result := DllCall("SETUPAPI\SetupInstallServicesFromInfSectionW"
, "Ptr", InfHandle ; void*
, "WStr", SectionName ; LPCWSTR
, "UInt", Flags ; SPSVCINST_FLAGS
, "Int") ; return: BOOL●SetupInstallServicesFromInfSectionW(InfHandle, SectionName, Flags) = DLL("SETUPAPI.dll", "bool SetupInstallServicesFromInfSectionW(void*, char*, dword)")
# 呼び出し: SetupInstallServicesFromInfSectionW(InfHandle, SectionName, Flags)
# InfHandle : void* -> "void*"
# SectionName : LPCWSTR -> "char*"
# Flags : SPSVCINST_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。