SetupDiGetActualSectionToInstallExA
関数シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupDiGetActualSectionToInstallExA(
void* InfHandle,
LPCSTR InfSectionName,
SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo, // optional
LPSTR InfSectionWithExt, // optional
DWORD InfSectionWithExtSize,
DWORD* RequiredSize, // optional
LPSTR* Extension, // optional
void* Reserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| InfHandle | void* | in | DDInstall セクションを含む INF ファイルへのハンドル。 | ||||||||
| InfSectionName | LPCSTR | in | DDInstall セクション名(INF Models セクションで指定されたもの)へのポインター。セクション名の最大長は 254 文字です。 | ||||||||
| AlternatePlatformInfo | SP_ALTPLATFORM_INFO_V2* | inoptional | NULL 以外の場合は、SP_ALTPLATFORM_INFO 構造体へのポインター。この構造体は、ローカル コンピューターとは異なるオペレーティング システムおよびプロセッサ アーキテクチャを指定するために使用します。ローカル コンピューターの DDInstall セクション名を取得するには、このパラメーターを NULL に設定します。それ以外の場合は、SP_ALTPLATFORM 構造体を指定し、そのメンバーを次のように設定します。 cbSizeSP_ALTPLATFORM_INFO 構造体のサイズ(バイト単位)を設定します。 PlatformWindows XP 以降の Windows では VER_PLATFORM_WIN32_NT を設定します。 MajorVersion使用されません。 MinorVersion使用されません。 ProcessorArchitecture次のプロセッサ アーキテクチャ定数のいずれかを設定します。
Reservedゼロに設定します。 | ||||||||
| InfSectionWithExt | LPSTR | outoptional | DDInstall セクション名、そのプラットフォーム拡張子、および NULL 終端文字を受け取る文字バッファーへのポインター。これはインストールに使用すべき装飾付きセクション名です。このパラメーターが NULL の場合、関数は TRUE を返し、RequiredSize に DDInstall セクション名、そのプラットフォーム拡張子、および終端の NULL 文字を返すために必要なサイズ(文字単位)を設定します。 | ||||||||
| InfSectionWithExtSize | DWORD | in | InfSectionWithExt パラメーターが指すバッファーのサイズ(文字単位)。NULL 終端の INF セクション名の最大長は、文字単位で MAX_INF_SECTION_NAME_LENGTH です。 | ||||||||
| RequiredSize | DWORD* | outoptional | DDInstall セクション名、プラットフォーム拡張子、および終端の NULL 文字を返すために必要なサイズ(文字単位)を受け取る変数へのポインター。 | ||||||||
| Extension | LPSTR* | outoptional | InfSectionWithExt バッファー内で拡張子の開始位置を示す '.' 文字へのポインターを受け取る変数へのポインター。InfSectionWithExt バッファーが指定されていない場合、または小さすぎる場合、このパラメーターは設定されません。拡張子へのポインターが不要な場合は、このパラメーターを NULL に設定します。 | ||||||||
| Reserved | void* | optional | 内部使用のために予約されています。NULL に設定する必要があります。 |
戻り値の型: BOOL
公式ドキュメント
SetupDiGetActualSectionToInstallEx 関数は、指定されたオペレーティング システムおよびプロセッサ アーキテクチャ向けにデバイスをインストールする INF の DDInstall セクションの名前を取得します。(ANSI)
戻り値
関数が成功した場合は TRUE を返します。それ以外の場合は FALSE を返します。拡張エラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
SetupDiGetActualSectionToInstallEx は SetupDiGetActualSectionToInstall の拡張形式です。これらの関数は、デバイスに対する OS 固有およびアーキテクチャ固有のインストール動作を指定するために使用される DDInstall セクション名の拡張子をサポートします。これらの拡張子については、複数のプラットフォームおよびオペレーティング システム向けの INF ファイルの作成を参照してください。
SetupDiGetActualSectionToInstallEx の呼び出しで代替プラットフォーム情報を指定しない場合、この関数は SetupDiGetActualSectionToInstall と同じ処理を行います。後者の関数は、ローカル コンピューターのプラットフォーム情報を使用して、指定されたインストール セクション名を検索します。
SetupDiGetActualSectionToInstallEx の呼び出しで代替プラットフォーム情報を指定した場合、この関数は次のように動作します。
-
プラットフォームとして VER_PLATFORM_WIN32_NT を指定した場合、関数はまず、指定された INF ファイル内で、指定した名前、オペレーティング システム、およびプロセッサ アーキテクチャに一致する装飾付きインストール セクション名を検索します。たとえば、インストール セクション名として InstallSec を指定した場合、関数は指定されたプロセッサ アーキテクチャに応じて、次のいずれかの装飾付き名前を検索します。
- x86 ベースのプロセッサ アーキテクチャを指定した場合、関数は装飾付き名前 InstallSec.ntx86 を検索します。
- x64 ベースのプロセッサ アーキテクチャを指定した場合、関数は装飾付き名前 InstallSec.ntamd64 を検索します。
- Itanium ベースのプロセッサ アーキテクチャを指定した場合、関数は装飾付き名前 InstallSec.ntia64 を検索します。
名前、オペレーティング システム、およびプロセッサ アーキテクチャに一致するものが見つかった場合、関数は検索を終了し、対応する装飾付き名前を返します。そのような一致が見つからない場合、関数は InstallSec.nt という名前のセクションを検索します。InstallSec.nt に一致するものが見つかった場合、関数は検索を終了し、この名前を返します。上記のいずれの検索でも一致が見つからない場合、関数は InstallSec を返しますが、INF ファイルに InstallSec という名前のインストール セクションが含まれているかどうかは検証しません。
setupapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして SetupDiGetActualSectionToInstallEx を定義しています。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在させて使用すると、不一致が生じてコンパイル エラーまたは実行時エラーの原因になることがあります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupDiGetActualSectionToInstallExA(
void* InfHandle,
LPCSTR InfSectionName,
SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo, // optional
LPSTR InfSectionWithExt, // optional
DWORD InfSectionWithExtSize,
DWORD* RequiredSize, // optional
LPSTR* Extension, // optional
void* Reserved // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupDiGetActualSectionToInstallExA(
IntPtr InfHandle, // void*
[MarshalAs(UnmanagedType.LPStr)] string InfSectionName, // LPCSTR
IntPtr AlternatePlatformInfo, // SP_ALTPLATFORM_INFO_V2* optional
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder InfSectionWithExt, // LPSTR optional, out
uint InfSectionWithExtSize, // DWORD
IntPtr RequiredSize, // DWORD* optional, out
IntPtr Extension, // LPSTR* optional, out
IntPtr Reserved // void* optional
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDiGetActualSectionToInstallExA(
InfHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> InfSectionName As String, ' LPCSTR
AlternatePlatformInfo As IntPtr, ' SP_ALTPLATFORM_INFO_V2* optional
<MarshalAs(UnmanagedType.LPStr)> InfSectionWithExt As System.Text.StringBuilder, ' LPSTR optional, out
InfSectionWithExtSize As UInteger, ' DWORD
RequiredSize As IntPtr, ' DWORD* optional, out
Extension As IntPtr, ' LPSTR* optional, out
Reserved As IntPtr ' void* optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' InfHandle : void*
' InfSectionName : LPCSTR
' AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
' InfSectionWithExt : LPSTR optional, out
' InfSectionWithExtSize : DWORD
' RequiredSize : DWORD* optional, out
' Extension : LPSTR* optional, out
' Reserved : void* optional
Declare PtrSafe Function SetupDiGetActualSectionToInstallExA Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal InfSectionName As String, _
ByVal AlternatePlatformInfo As LongPtr, _
ByVal InfSectionWithExt As String, _
ByVal InfSectionWithExtSize As Long, _
ByVal RequiredSize As LongPtr, _
ByVal Extension As LongPtr, _
ByVal Reserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupDiGetActualSectionToInstallExA = ctypes.windll.setupapi.SetupDiGetActualSectionToInstallExA
SetupDiGetActualSectionToInstallExA.restype = wintypes.BOOL
SetupDiGetActualSectionToInstallExA.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
wintypes.LPCSTR, # InfSectionName : LPCSTR
ctypes.c_void_p, # AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
wintypes.LPSTR, # InfSectionWithExt : LPSTR optional, out
wintypes.DWORD, # InfSectionWithExtSize : DWORD
ctypes.POINTER(wintypes.DWORD), # RequiredSize : DWORD* optional, out
ctypes.c_void_p, # Extension : LPSTR* optional, out
ctypes.POINTER(None), # Reserved : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiGetActualSectionToInstallExA = Fiddle::Function.new(
lib['SetupDiGetActualSectionToInstallExA'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # InfSectionName : LPCSTR
Fiddle::TYPE_VOIDP, # AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
Fiddle::TYPE_VOIDP, # InfSectionWithExt : LPSTR optional, out
-Fiddle::TYPE_INT, # InfSectionWithExtSize : DWORD
Fiddle::TYPE_VOIDP, # RequiredSize : DWORD* optional, out
Fiddle::TYPE_VOIDP, # Extension : LPSTR* optional, out
Fiddle::TYPE_VOIDP, # Reserved : void* optional
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupDiGetActualSectionToInstallExA(
InfHandle: *mut (), // void*
InfSectionName: *const u8, // LPCSTR
AlternatePlatformInfo: *mut SP_ALTPLATFORM_INFO_V2, // SP_ALTPLATFORM_INFO_V2* optional
InfSectionWithExt: *mut u8, // LPSTR optional, out
InfSectionWithExtSize: u32, // DWORD
RequiredSize: *mut u32, // DWORD* optional, out
Extension: *mut *mut u8, // LPSTR* optional, out
Reserved: *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 SetupDiGetActualSectionToInstallExA(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string InfSectionName, IntPtr AlternatePlatformInfo, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder InfSectionWithExt, uint InfSectionWithExtSize, IntPtr RequiredSize, IntPtr Extension, IntPtr Reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiGetActualSectionToInstallExA' -Namespace Win32 -PassThru
# $api::SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)#uselib "SETUPAPI.dll"
#func global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupDiGetActualSectionToInstallExA InfHandle, InfSectionName, varptr(AlternatePlatformInfo), varptr(InfSectionWithExt), InfSectionWithExtSize, varptr(RequiredSize), varptr(Extension), Reserved ; 戻り値は stat
; InfHandle : void* -> "sptr"
; InfSectionName : LPCSTR -> "sptr"
; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "sptr"
; InfSectionWithExt : LPSTR optional, out -> "sptr"
; InfSectionWithExtSize : DWORD -> "sptr"
; RequiredSize : DWORD* optional, out -> "sptr"
; Extension : LPSTR* optional, out -> "sptr"
; Reserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll" #cfunc global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" sptr, str, var, var, int, var, var, sptr ; res = SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved) ; InfHandle : void* -> "sptr" ; InfSectionName : LPCSTR -> "str" ; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "var" ; InfSectionWithExt : LPSTR optional, out -> "var" ; InfSectionWithExtSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; Extension : LPSTR* optional, out -> "var" ; Reserved : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" sptr, str, sptr, sptr, int, sptr, sptr, sptr ; res = SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, varptr(AlternatePlatformInfo), varptr(InfSectionWithExt), InfSectionWithExtSize, varptr(RequiredSize), varptr(Extension), Reserved) ; InfHandle : void* -> "sptr" ; InfSectionName : LPCSTR -> "str" ; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "sptr" ; InfSectionWithExt : LPSTR optional, out -> "sptr" ; InfSectionWithExtSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "sptr" ; Extension : LPSTR* optional, out -> "sptr" ; Reserved : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; BOOL SetupDiGetActualSectionToInstallExA(void* InfHandle, LPCSTR InfSectionName, SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo, LPSTR InfSectionWithExt, DWORD InfSectionWithExtSize, DWORD* RequiredSize, LPSTR* Extension, void* Reserved) #uselib "SETUPAPI.dll" #cfunc global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" intptr, str, var, var, int, var, var, intptr ; res = SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved) ; InfHandle : void* -> "intptr" ; InfSectionName : LPCSTR -> "str" ; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "var" ; InfSectionWithExt : LPSTR optional, out -> "var" ; InfSectionWithExtSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; Extension : LPSTR* optional, out -> "var" ; Reserved : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupDiGetActualSectionToInstallExA(void* InfHandle, LPCSTR InfSectionName, SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo, LPSTR InfSectionWithExt, DWORD InfSectionWithExtSize, DWORD* RequiredSize, LPSTR* Extension, void* Reserved) #uselib "SETUPAPI.dll" #cfunc global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" intptr, str, intptr, intptr, int, intptr, intptr, intptr ; res = SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, varptr(AlternatePlatformInfo), varptr(InfSectionWithExt), InfSectionWithExtSize, varptr(RequiredSize), varptr(Extension), Reserved) ; InfHandle : void* -> "intptr" ; InfSectionName : LPCSTR -> "str" ; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "intptr" ; InfSectionWithExt : LPSTR optional, out -> "intptr" ; InfSectionWithExtSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "intptr" ; Extension : LPSTR* optional, out -> "intptr" ; Reserved : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupDiGetActualSectionToInstallExA = setupapi.NewProc("SetupDiGetActualSectionToInstallExA")
)
// InfHandle (void*), InfSectionName (LPCSTR), AlternatePlatformInfo (SP_ALTPLATFORM_INFO_V2* optional), InfSectionWithExt (LPSTR optional, out), InfSectionWithExtSize (DWORD), RequiredSize (DWORD* optional, out), Extension (LPSTR* optional, out), Reserved (void* optional)
r1, _, err := procSetupDiGetActualSectionToInstallExA.Call(
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.BytePtrFromString(InfSectionName))),
uintptr(AlternatePlatformInfo),
uintptr(InfSectionWithExt),
uintptr(InfSectionWithExtSize),
uintptr(RequiredSize),
uintptr(Extension),
uintptr(Reserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupDiGetActualSectionToInstallExA(
InfHandle: Pointer; // void*
InfSectionName: PAnsiChar; // LPCSTR
AlternatePlatformInfo: Pointer; // SP_ALTPLATFORM_INFO_V2* optional
InfSectionWithExt: PAnsiChar; // LPSTR optional, out
InfSectionWithExtSize: DWORD; // DWORD
RequiredSize: Pointer; // DWORD* optional, out
Extension: PPAnsiChar; // LPSTR* optional, out
Reserved: Pointer // void* optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiGetActualSectionToInstallExA';result := DllCall("SETUPAPI\SetupDiGetActualSectionToInstallExA"
, "Ptr", InfHandle ; void*
, "AStr", InfSectionName ; LPCSTR
, "Ptr", AlternatePlatformInfo ; SP_ALTPLATFORM_INFO_V2* optional
, "Ptr", InfSectionWithExt ; LPSTR optional, out
, "UInt", InfSectionWithExtSize ; DWORD
, "Ptr", RequiredSize ; DWORD* optional, out
, "Ptr", Extension ; LPSTR* optional, out
, "Ptr", Reserved ; void* optional
, "Int") ; return: BOOL●SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved) = DLL("SETUPAPI.dll", "bool SetupDiGetActualSectionToInstallExA(void*, char*, void*, char*, dword, void*, void*, void*)")
# 呼び出し: SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
# InfHandle : void* -> "void*"
# InfSectionName : LPCSTR -> "char*"
# AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "void*"
# InfSectionWithExt : LPSTR optional, out -> "char*"
# InfSectionWithExtSize : DWORD -> "dword"
# RequiredSize : DWORD* optional, out -> "void*"
# Extension : LPSTR* optional, out -> "void*"
# Reserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "setupapi" fn SetupDiGetActualSectionToInstallExA(
InfHandle: ?*anyopaque, // void*
InfSectionName: [*c]const u8, // LPCSTR
AlternatePlatformInfo: [*c]SP_ALTPLATFORM_INFO_V2, // SP_ALTPLATFORM_INFO_V2* optional
InfSectionWithExt: [*c]u8, // LPSTR optional, out
InfSectionWithExtSize: u32, // DWORD
RequiredSize: [*c]u32, // DWORD* optional, out
Extension: [*c][*c]u8, // LPSTR* optional, out
Reserved: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc SetupDiGetActualSectionToInstallExA(
InfHandle: pointer, # void*
InfSectionName: cstring, # LPCSTR
AlternatePlatformInfo: ptr SP_ALTPLATFORM_INFO_V2, # SP_ALTPLATFORM_INFO_V2* optional
InfSectionWithExt: ptr char, # LPSTR optional, out
InfSectionWithExtSize: uint32, # DWORD
RequiredSize: ptr uint32, # DWORD* optional, out
Extension: ptr cstring, # LPSTR* optional, out
Reserved: pointer # void* optional
): int32 {.importc: "SetupDiGetActualSectionToInstallExA", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupDiGetActualSectionToInstallExA(
void* InfHandle, // void*
const(char)* InfSectionName, // LPCSTR
SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo, // SP_ALTPLATFORM_INFO_V2* optional
char* InfSectionWithExt, // LPSTR optional, out
uint InfSectionWithExtSize, // DWORD
uint* RequiredSize, // DWORD* optional, out
char** Extension, // LPSTR* optional, out
void* Reserved // void* optional
);ccall((:SetupDiGetActualSectionToInstallExA, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cstring, Ptr{SP_ALTPLATFORM_INFO_V2}, Ptr{UInt8}, UInt32, Ptr{UInt32}, Ptr{Ptr{UInt8}}, Ptr{Cvoid}),
InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
# InfHandle : void* -> Ptr{Cvoid}
# InfSectionName : LPCSTR -> Cstring
# AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> Ptr{SP_ALTPLATFORM_INFO_V2}
# InfSectionWithExt : LPSTR optional, out -> Ptr{UInt8}
# InfSectionWithExtSize : DWORD -> UInt32
# RequiredSize : DWORD* optional, out -> Ptr{UInt32}
# Extension : LPSTR* optional, out -> Ptr{Ptr{UInt8}}
# Reserved : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupDiGetActualSectionToInstallExA(
void* InfHandle,
const char* InfSectionName,
void* AlternatePlatformInfo,
char* InfSectionWithExt,
uint32_t InfSectionWithExtSize,
uint32_t* RequiredSize,
char** Extension,
void* Reserved);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
-- InfHandle : void*
-- InfSectionName : LPCSTR
-- AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
-- InfSectionWithExt : LPSTR optional, out
-- InfSectionWithExtSize : DWORD
-- RequiredSize : DWORD* optional, out
-- Extension : LPSTR* optional, out
-- Reserved : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupDiGetActualSectionToInstallExA = lib.func('__stdcall', 'SetupDiGetActualSectionToInstallExA', 'int32_t', ['void *', 'str', 'void *', 'char *', 'uint32_t', 'uint32_t *', 'void *', 'void *']);
// SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
// InfHandle : void* -> 'void *'
// InfSectionName : LPCSTR -> 'str'
// AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> 'void *'
// InfSectionWithExt : LPSTR optional, out -> 'char *'
// InfSectionWithExtSize : DWORD -> 'uint32_t'
// RequiredSize : DWORD* optional, out -> 'uint32_t *'
// Extension : LPSTR* optional, out -> 'void *'
// Reserved : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupDiGetActualSectionToInstallExA: { parameters: ["pointer", "buffer", "pointer", "buffer", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
// InfHandle : void* -> "pointer"
// InfSectionName : LPCSTR -> "buffer"
// AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "pointer"
// InfSectionWithExt : LPSTR optional, out -> "buffer"
// InfSectionWithExtSize : DWORD -> "u32"
// RequiredSize : DWORD* optional, out -> "pointer"
// Extension : LPSTR* optional, out -> "pointer"
// Reserved : void* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupDiGetActualSectionToInstallExA(
void* InfHandle,
const char* InfSectionName,
void* AlternatePlatformInfo,
char* InfSectionWithExt,
uint32_t InfSectionWithExtSize,
uint32_t* RequiredSize,
char** Extension,
void* Reserved);
C, "SETUPAPI.dll");
// $ffi->SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved);
// InfHandle : void*
// InfSectionName : LPCSTR
// AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
// InfSectionWithExt : LPSTR optional, out
// InfSectionWithExtSize : DWORD
// RequiredSize : DWORD* optional, out
// Extension : LPSTR* optional, out
// Reserved : 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 SetupDiGetActualSectionToInstallExA(
Pointer InfHandle, // void*
String InfSectionName, // LPCSTR
Pointer AlternatePlatformInfo, // SP_ALTPLATFORM_INFO_V2* optional
byte[] InfSectionWithExt, // LPSTR optional, out
int InfSectionWithExtSize, // DWORD
IntByReference RequiredSize, // DWORD* optional, out
PointerByReference Extension, // LPSTR* optional, out
Pointer Reserved // void* optional
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupDiGetActualSectionToInstallExA = SetupDiGetActualSectionToInstallExA(
InfHandle : Void*, # void*
InfSectionName : UInt8*, # LPCSTR
AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2*, # SP_ALTPLATFORM_INFO_V2* optional
InfSectionWithExt : UInt8*, # LPSTR optional, out
InfSectionWithExtSize : UInt32, # DWORD
RequiredSize : UInt32*, # DWORD* optional, out
Extension : UInt8**, # LPSTR* optional, out
Reserved : 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 SetupDiGetActualSectionToInstallExANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Void>, Pointer<Utf8>, Uint32, Pointer<Uint32>, Pointer<Pointer<Utf8>>, Pointer<Void>);
typedef SetupDiGetActualSectionToInstallExADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Void>, Pointer<Utf8>, int, Pointer<Uint32>, Pointer<Pointer<Utf8>>, Pointer<Void>);
final SetupDiGetActualSectionToInstallExA = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupDiGetActualSectionToInstallExANative, SetupDiGetActualSectionToInstallExADart>('SetupDiGetActualSectionToInstallExA');
// InfHandle : void* -> Pointer<Void>
// InfSectionName : LPCSTR -> Pointer<Utf8>
// AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> Pointer<Void>
// InfSectionWithExt : LPSTR optional, out -> Pointer<Utf8>
// InfSectionWithExtSize : DWORD -> Uint32
// RequiredSize : DWORD* optional, out -> Pointer<Uint32>
// Extension : LPSTR* optional, out -> Pointer<Pointer<Utf8>>
// Reserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupDiGetActualSectionToInstallExA(
InfHandle: Pointer; // void*
InfSectionName: PAnsiChar; // LPCSTR
AlternatePlatformInfo: Pointer; // SP_ALTPLATFORM_INFO_V2* optional
InfSectionWithExt: PAnsiChar; // LPSTR optional, out
InfSectionWithExtSize: DWORD; // DWORD
RequiredSize: Pointer; // DWORD* optional, out
Extension: PPAnsiChar; // LPSTR* optional, out
Reserved: Pointer // void* optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiGetActualSectionToInstallExA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupDiGetActualSectionToInstallExA"
c_SetupDiGetActualSectionToInstallExA :: Ptr () -> CString -> Ptr () -> CString -> Word32 -> Ptr Word32 -> Ptr CString -> Ptr () -> IO CInt
-- InfHandle : void* -> Ptr ()
-- InfSectionName : LPCSTR -> CString
-- AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> Ptr ()
-- InfSectionWithExt : LPSTR optional, out -> CString
-- InfSectionWithExtSize : DWORD -> Word32
-- RequiredSize : DWORD* optional, out -> Ptr Word32
-- Extension : LPSTR* optional, out -> Ptr CString
-- Reserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupdigetactualsectiontoinstallexa =
foreign "SetupDiGetActualSectionToInstallExA"
((ptr void) @-> string @-> (ptr void) @-> string @-> uint32_t @-> (ptr uint32_t) @-> (ptr string) @-> (ptr void) @-> returning int32_t)
(* InfHandle : void* -> (ptr void) *)
(* InfSectionName : LPCSTR -> string *)
(* AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> (ptr void) *)
(* InfSectionWithExt : LPSTR optional, out -> string *)
(* InfSectionWithExtSize : DWORD -> uint32_t *)
(* RequiredSize : DWORD* optional, out -> (ptr uint32_t) *)
(* Extension : LPSTR* optional, out -> (ptr string) *)
(* Reserved : 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 ("SetupDiGetActualSectionToInstallExA" setup-di-get-actual-section-to-install-ex-a :convention :stdcall) :int32
(inf-handle :pointer) ; void*
(inf-section-name :string) ; LPCSTR
(alternate-platform-info :pointer) ; SP_ALTPLATFORM_INFO_V2* optional
(inf-section-with-ext :pointer) ; LPSTR optional, out
(inf-section-with-ext-size :uint32) ; DWORD
(required-size :pointer) ; DWORD* optional, out
(extension :pointer) ; LPSTR* optional, out
(reserved :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupDiGetActualSectionToInstallExA = Win32::API::More->new('SETUPAPI',
'BOOL SetupDiGetActualSectionToInstallExA(LPVOID InfHandle, LPCSTR InfSectionName, LPVOID AlternatePlatformInfo, LPSTR InfSectionWithExt, DWORD InfSectionWithExtSize, LPVOID RequiredSize, LPVOID Extension, LPVOID Reserved)');
# my $ret = $SetupDiGetActualSectionToInstallExA->Call($InfHandle, $InfSectionName, $AlternatePlatformInfo, $InfSectionWithExt, $InfSectionWithExtSize, $RequiredSize, $Extension, $Reserved);
# InfHandle : void* -> LPVOID
# InfSectionName : LPCSTR -> LPCSTR
# AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> LPVOID
# InfSectionWithExt : LPSTR optional, out -> LPSTR
# InfSectionWithExtSize : DWORD -> DWORD
# RequiredSize : DWORD* optional, out -> LPVOID
# Extension : LPSTR* optional, out -> LPVOID
# Reserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f SetupDiGetActualSectionToInstallExW (Unicode版) — 指定プラットフォームでインストールする実際のINFセクション名を取得する。
- f SetupDiGetActualSectionToInstallA — INFでインストールに使用する実際のセクション名を取得する。
- f SetupDiInstallDevice — 選択されたドライバを用いてデバイスをインストールする。