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サービス情報を記述したINFファイルのハンドル。
SectionNameLPCSTRinサービスインストールを記述したINFのセクション名(ANSI)。
FlagsSPSVCINST_FLAGSinSPSVCINST_*系のサービスインストール動作フラグ。
DeviceInfoSetHDEVINFOinoptional関連付けるデバイス情報セットのハンドル。NULL可。
DeviceInfoDataSP_DEVINFO_DATA*inoptional対象デバイスを示すSP_DEVINFO_DATA構造体へのポインタ。NULL可。
Reserved1void*optional予約済み。NULLを指定する必要がある。
Reserved2void*optional予約済み。NULLを指定する必要がある。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "setupapi" fn SetupInstallServicesFromInfSectionExA(
    InfHandle: ?*anyopaque, // void*
    SectionName: [*c]const u8, // LPCSTR
    Flags: u32, // SPSVCINST_FLAGS
    DeviceInfoSet: isize, // HDEVINFO optional
    DeviceInfoData: [*c]SP_DEVINFO_DATA, // SP_DEVINFO_DATA* optional
    Reserved1: ?*anyopaque, // void* optional
    Reserved2: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;
proc SetupInstallServicesFromInfSectionExA(
    InfHandle: pointer,  # void*
    SectionName: cstring,  # LPCSTR
    Flags: uint32,  # SPSVCINST_FLAGS
    DeviceInfoSet: int,  # HDEVINFO optional
    DeviceInfoData: ptr SP_DEVINFO_DATA,  # SP_DEVINFO_DATA* optional
    Reserved1: pointer,  # void* optional
    Reserved2: pointer  # void* optional
): int32 {.importc: "SetupInstallServicesFromInfSectionExA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupInstallServicesFromInfSectionExA(
    void* InfHandle,   // void*
    const(char)* SectionName,   // LPCSTR
    uint Flags,   // SPSVCINST_FLAGS
    ptrdiff_t DeviceInfoSet,   // HDEVINFO optional
    SP_DEVINFO_DATA* DeviceInfoData,   // SP_DEVINFO_DATA* optional
    void* Reserved1,   // void* optional
    void* Reserved2   // void* optional
);
ccall((:SetupInstallServicesFromInfSectionExA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cstring, UInt32, Int, Ptr{SP_DEVINFO_DATA}, Ptr{Cvoid}, Ptr{Cvoid}),
      InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
# InfHandle : void* -> Ptr{Cvoid}
# SectionName : LPCSTR -> Cstring
# Flags : SPSVCINST_FLAGS -> UInt32
# DeviceInfoSet : HDEVINFO optional -> Int
# DeviceInfoData : SP_DEVINFO_DATA* optional -> Ptr{SP_DEVINFO_DATA}
# Reserved1 : void* optional -> Ptr{Cvoid}
# Reserved2 : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupInstallServicesFromInfSectionExA(
    void* InfHandle,
    const char* SectionName,
    uint32_t Flags,
    intptr_t DeviceInfoSet,
    void* DeviceInfoData,
    void* Reserved1,
    void* Reserved2);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
-- InfHandle : void*
-- SectionName : LPCSTR
-- Flags : SPSVCINST_FLAGS
-- DeviceInfoSet : HDEVINFO optional
-- DeviceInfoData : SP_DEVINFO_DATA* optional
-- Reserved1 : void* optional
-- Reserved2 : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupInstallServicesFromInfSectionExA = lib.func('__stdcall', 'SetupInstallServicesFromInfSectionExA', 'int32_t', ['void *', 'str', 'uint32_t', 'intptr_t', 'void *', 'void *', 'void *']);
// SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
// InfHandle : void* -> 'void *'
// SectionName : LPCSTR -> 'str'
// Flags : SPSVCINST_FLAGS -> 'uint32_t'
// DeviceInfoSet : HDEVINFO optional -> 'intptr_t'
// DeviceInfoData : SP_DEVINFO_DATA* optional -> 'void *'
// Reserved1 : void* optional -> 'void *'
// Reserved2 : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupInstallServicesFromInfSectionExA: { parameters: ["pointer", "buffer", "u32", "isize", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2)
// InfHandle : void* -> "pointer"
// SectionName : LPCSTR -> "buffer"
// Flags : SPSVCINST_FLAGS -> "u32"
// DeviceInfoSet : HDEVINFO optional -> "isize"
// DeviceInfoData : SP_DEVINFO_DATA* optional -> "pointer"
// Reserved1 : void* optional -> "pointer"
// Reserved2 : void* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupInstallServicesFromInfSectionExA(
    void* InfHandle,
    const char* SectionName,
    uint32_t Flags,
    intptr_t DeviceInfoSet,
    void* DeviceInfoData,
    void* Reserved1,
    void* Reserved2);
C, "SETUPAPI.dll");
// $ffi->SetupInstallServicesFromInfSectionExA(InfHandle, SectionName, Flags, DeviceInfoSet, DeviceInfoData, Reserved1, Reserved2);
// InfHandle : void*
// SectionName : LPCSTR
// Flags : SPSVCINST_FLAGS
// DeviceInfoSet : HDEVINFO optional
// DeviceInfoData : SP_DEVINFO_DATA* optional
// Reserved1 : void* optional
// Reserved2 : void* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Setupapi extends StdCallLibrary {
    Setupapi INSTANCE = Native.load("setupapi", Setupapi.class, W32APIOptions.ASCII_OPTIONS);
    boolean SetupInstallServicesFromInfSectionExA(
        Pointer InfHandle,   // void*
        String SectionName,   // LPCSTR
        int Flags,   // SPSVCINST_FLAGS
        long DeviceInfoSet,   // HDEVINFO optional
        Pointer DeviceInfoData,   // SP_DEVINFO_DATA* optional
        Pointer Reserved1,   // void* optional
        Pointer Reserved2   // void* optional
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupInstallServicesFromInfSectionExA = SetupInstallServicesFromInfSectionExA(
    InfHandle : Void*,   # void*
    SectionName : UInt8*,   # LPCSTR
    Flags : UInt32,   # SPSVCINST_FLAGS
    DeviceInfoSet : LibC::SSizeT,   # HDEVINFO optional
    DeviceInfoData : SP_DEVINFO_DATA*,   # SP_DEVINFO_DATA* optional
    Reserved1 : Void*,   # void* optional
    Reserved2 : Void*   # void* optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetupInstallServicesFromInfSectionExANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Uint32, IntPtr, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef SetupInstallServicesFromInfSectionExADart = int Function(Pointer<Void>, Pointer<Utf8>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final SetupInstallServicesFromInfSectionExA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupInstallServicesFromInfSectionExANative, SetupInstallServicesFromInfSectionExADart>('SetupInstallServicesFromInfSectionExA');
// InfHandle : void* -> Pointer<Void>
// SectionName : LPCSTR -> Pointer<Utf8>
// Flags : SPSVCINST_FLAGS -> Uint32
// DeviceInfoSet : HDEVINFO optional -> IntPtr
// DeviceInfoData : SP_DEVINFO_DATA* optional -> Pointer<Void>
// Reserved1 : void* optional -> Pointer<Void>
// Reserved2 : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupInstallServicesFromInfSectionExA"
  c_SetupInstallServicesFromInfSectionExA :: Ptr () -> CString -> Word32 -> CIntPtr -> Ptr () -> Ptr () -> Ptr () -> IO CInt
-- InfHandle : void* -> Ptr ()
-- SectionName : LPCSTR -> CString
-- Flags : SPSVCINST_FLAGS -> Word32
-- DeviceInfoSet : HDEVINFO optional -> CIntPtr
-- DeviceInfoData : SP_DEVINFO_DATA* optional -> Ptr ()
-- Reserved1 : void* optional -> Ptr ()
-- Reserved2 : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupinstallservicesfrominfsectionexa =
  foreign "SetupInstallServicesFromInfSectionExA"
    ((ptr void) @-> string @-> uint32_t @-> intptr_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* InfHandle : void* -> (ptr void) *)
(* SectionName : LPCSTR -> string *)
(* Flags : SPSVCINST_FLAGS -> uint32_t *)
(* DeviceInfoSet : HDEVINFO optional -> intptr_t *)
(* DeviceInfoData : SP_DEVINFO_DATA* optional -> (ptr void) *)
(* Reserved1 : void* optional -> (ptr void) *)
(* Reserved2 : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)

(cffi:defcfun ("SetupInstallServicesFromInfSectionExA" setup-install-services-from-inf-section-ex-a :convention :stdcall) :int32
  (inf-handle :pointer)   ; void*
  (section-name :string)   ; LPCSTR
  (flags :uint32)   ; SPSVCINST_FLAGS
  (device-info-set :int64)   ; HDEVINFO optional
  (device-info-data :pointer)   ; SP_DEVINFO_DATA* optional
  (reserved1 :pointer)   ; void* optional
  (reserved2 :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupInstallServicesFromInfSectionExA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupInstallServicesFromInfSectionExA(LPVOID InfHandle, LPCSTR SectionName, DWORD Flags, LPARAM DeviceInfoSet, LPVOID DeviceInfoData, LPVOID Reserved1, LPVOID Reserved2)');
# my $ret = $SetupInstallServicesFromInfSectionExA->Call($InfHandle, $SectionName, $Flags, $DeviceInfoSet, $DeviceInfoData, $Reserved1, $Reserved2);
# InfHandle : void* -> LPVOID
# SectionName : LPCSTR -> LPCSTR
# Flags : SPSVCINST_FLAGS -> DWORD
# DeviceInfoSet : HDEVINFO optional -> LPARAM
# DeviceInfoData : SP_DEVINFO_DATA* optional -> LPVOID
# Reserved1 : void* optional -> LPVOID
# Reserved2 : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
類似 API
使用する型