ホーム › Devices.DeviceAndDriverInstallation › SetupGetSourceInfoA
SetupGetSourceInfoA
関数INFの指定ソースの情報(パスやタグ等)を取得する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupGetSourceInfoA(
void* InfHandle,
DWORD SourceId,
DWORD InfoDesired,
LPSTR ReturnBuffer, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| InfHandle | void* | in |
| SourceId | DWORD | in |
| InfoDesired | DWORD | in |
| ReturnBuffer | LPSTR | outoptional |
| ReturnBufferSize | DWORD | in |
| RequiredSize | DWORD* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupGetSourceInfoA(
void* InfHandle,
DWORD SourceId,
DWORD InfoDesired,
LPSTR ReturnBuffer, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupGetSourceInfoA(
IntPtr InfHandle, // void*
uint SourceId, // DWORD
uint InfoDesired, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder ReturnBuffer, // LPSTR optional, out
uint ReturnBufferSize, // DWORD
IntPtr RequiredSize // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupGetSourceInfoA(
InfHandle As IntPtr, ' void*
SourceId As UInteger, ' DWORD
InfoDesired As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> ReturnBuffer As System.Text.StringBuilder, ' LPSTR optional, out
ReturnBufferSize As UInteger, ' DWORD
RequiredSize As IntPtr ' DWORD* optional, out
) As Boolean
End Function' InfHandle : void*
' SourceId : DWORD
' InfoDesired : DWORD
' ReturnBuffer : LPSTR optional, out
' ReturnBufferSize : DWORD
' RequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupGetSourceInfoA Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal SourceId As Long, _
ByVal InfoDesired As Long, _
ByVal ReturnBuffer As String, _
ByVal ReturnBufferSize As Long, _
ByVal RequiredSize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupGetSourceInfoA = ctypes.windll.setupapi.SetupGetSourceInfoA
SetupGetSourceInfoA.restype = wintypes.BOOL
SetupGetSourceInfoA.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
wintypes.DWORD, # SourceId : DWORD
wintypes.DWORD, # InfoDesired : DWORD
wintypes.LPSTR, # ReturnBuffer : LPSTR optional, out
wintypes.DWORD, # ReturnBufferSize : DWORD
ctypes.POINTER(wintypes.DWORD), # RequiredSize : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupGetSourceInfoA = Fiddle::Function.new(
lib['SetupGetSourceInfoA'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
-Fiddle::TYPE_INT, # SourceId : DWORD
-Fiddle::TYPE_INT, # InfoDesired : DWORD
Fiddle::TYPE_VOIDP, # ReturnBuffer : LPSTR optional, out
-Fiddle::TYPE_INT, # ReturnBufferSize : DWORD
Fiddle::TYPE_VOIDP, # RequiredSize : DWORD* optional, out
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupGetSourceInfoA(
InfHandle: *mut (), // void*
SourceId: u32, // DWORD
InfoDesired: u32, // DWORD
ReturnBuffer: *mut u8, // LPSTR optional, out
ReturnBufferSize: u32, // DWORD
RequiredSize: *mut u32 // DWORD* optional, out
) -> 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 SetupGetSourceInfoA(IntPtr InfHandle, uint SourceId, uint InfoDesired, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder ReturnBuffer, uint ReturnBufferSize, IntPtr RequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupGetSourceInfoA' -Namespace Win32 -PassThru
# $api::SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, ReturnBuffer, ReturnBufferSize, RequiredSize)#uselib "SETUPAPI.dll"
#func global SetupGetSourceInfoA "SetupGetSourceInfoA" sptr, sptr, sptr, sptr, sptr, sptr
; SetupGetSourceInfoA InfHandle, SourceId, InfoDesired, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize) ; 戻り値は stat
; InfHandle : void* -> "sptr"
; SourceId : DWORD -> "sptr"
; InfoDesired : DWORD -> "sptr"
; ReturnBuffer : LPSTR optional, out -> "sptr"
; ReturnBufferSize : DWORD -> "sptr"
; RequiredSize : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupGetSourceInfoA "SetupGetSourceInfoA" sptr, int, int, var, int, var ; res = SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, ReturnBuffer, ReturnBufferSize, RequiredSize) ; InfHandle : void* -> "sptr" ; SourceId : DWORD -> "int" ; InfoDesired : DWORD -> "int" ; ReturnBuffer : LPSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupGetSourceInfoA "SetupGetSourceInfoA" sptr, int, int, sptr, int, sptr ; res = SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize)) ; InfHandle : void* -> "sptr" ; SourceId : DWORD -> "int" ; InfoDesired : DWORD -> "int" ; ReturnBuffer : LPSTR optional, out -> "sptr" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupGetSourceInfoA(void* InfHandle, DWORD SourceId, DWORD InfoDesired, LPSTR ReturnBuffer, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupGetSourceInfoA "SetupGetSourceInfoA" intptr, int, int, var, int, var ; res = SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, ReturnBuffer, ReturnBufferSize, RequiredSize) ; InfHandle : void* -> "intptr" ; SourceId : DWORD -> "int" ; InfoDesired : DWORD -> "int" ; ReturnBuffer : LPSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupGetSourceInfoA(void* InfHandle, DWORD SourceId, DWORD InfoDesired, LPSTR ReturnBuffer, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupGetSourceInfoA "SetupGetSourceInfoA" intptr, int, int, intptr, int, intptr ; res = SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize)) ; InfHandle : void* -> "intptr" ; SourceId : DWORD -> "int" ; InfoDesired : DWORD -> "int" ; ReturnBuffer : LPSTR optional, out -> "intptr" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupGetSourceInfoA = setupapi.NewProc("SetupGetSourceInfoA")
)
// InfHandle (void*), SourceId (DWORD), InfoDesired (DWORD), ReturnBuffer (LPSTR optional, out), ReturnBufferSize (DWORD), RequiredSize (DWORD* optional, out)
r1, _, err := procSetupGetSourceInfoA.Call(
uintptr(InfHandle),
uintptr(SourceId),
uintptr(InfoDesired),
uintptr(ReturnBuffer),
uintptr(ReturnBufferSize),
uintptr(RequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupGetSourceInfoA(
InfHandle: Pointer; // void*
SourceId: DWORD; // DWORD
InfoDesired: DWORD; // DWORD
ReturnBuffer: PAnsiChar; // LPSTR optional, out
ReturnBufferSize: DWORD; // DWORD
RequiredSize: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupGetSourceInfoA';result := DllCall("SETUPAPI\SetupGetSourceInfoA"
, "Ptr", InfHandle ; void*
, "UInt", SourceId ; DWORD
, "UInt", InfoDesired ; DWORD
, "Ptr", ReturnBuffer ; LPSTR optional, out
, "UInt", ReturnBufferSize ; DWORD
, "Ptr", RequiredSize ; DWORD* optional, out
, "Int") ; return: BOOL●SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, ReturnBuffer, ReturnBufferSize, RequiredSize) = DLL("SETUPAPI.dll", "bool SetupGetSourceInfoA(void*, dword, dword, char*, dword, void*)")
# 呼び出し: SetupGetSourceInfoA(InfHandle, SourceId, InfoDesired, ReturnBuffer, ReturnBufferSize, RequiredSize)
# InfHandle : void* -> "void*"
# SourceId : DWORD -> "dword"
# InfoDesired : DWORD -> "dword"
# ReturnBuffer : LPSTR optional, out -> "char*"
# ReturnBufferSize : DWORD -> "dword"
# RequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。