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