ホーム › Devices.DeviceAndDriverInstallation › SetupGetLineTextA
SetupGetLineTextA
関数INFの指定行またはキーのテキストを取得する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupGetLineTextA(
INFCONTEXT* Context, // optional
void* InfHandle, // optional
LPCSTR Section, // optional
LPCSTR Key, // optional
LPSTR ReturnBuffer, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Context | INFCONTEXT* | inoptional |
| InfHandle | void* | inoptional |
| Section | LPCSTR | inoptional |
| Key | LPCSTR | inoptional |
| ReturnBuffer | LPSTR | outoptional |
| ReturnBufferSize | DWORD | in |
| RequiredSize | DWORD* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupGetLineTextA(
INFCONTEXT* Context, // optional
void* InfHandle, // optional
LPCSTR Section, // optional
LPCSTR Key, // optional
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 SetupGetLineTextA(
IntPtr Context, // INFCONTEXT* optional
IntPtr InfHandle, // void* optional
[MarshalAs(UnmanagedType.LPStr)] string Section, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string Key, // LPCSTR optional
[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 SetupGetLineTextA(
Context As IntPtr, ' INFCONTEXT* optional
InfHandle As IntPtr, ' void* optional
<MarshalAs(UnmanagedType.LPStr)> Section As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> Key As String, ' LPCSTR optional
<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' Context : INFCONTEXT* optional
' InfHandle : void* optional
' Section : LPCSTR optional
' Key : LPCSTR optional
' ReturnBuffer : LPSTR optional, out
' ReturnBufferSize : DWORD
' RequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupGetLineTextA Lib "setupapi" ( _
ByVal Context As LongPtr, _
ByVal InfHandle As LongPtr, _
ByVal Section As String, _
ByVal Key As String, _
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
SetupGetLineTextA = ctypes.windll.setupapi.SetupGetLineTextA
SetupGetLineTextA.restype = wintypes.BOOL
SetupGetLineTextA.argtypes = [
ctypes.c_void_p, # Context : INFCONTEXT* optional
ctypes.POINTER(None), # InfHandle : void* optional
wintypes.LPCSTR, # Section : LPCSTR optional
wintypes.LPCSTR, # Key : LPCSTR optional
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')
SetupGetLineTextA = Fiddle::Function.new(
lib['SetupGetLineTextA'],
[
Fiddle::TYPE_VOIDP, # Context : INFCONTEXT* optional
Fiddle::TYPE_VOIDP, # InfHandle : void* optional
Fiddle::TYPE_VOIDP, # Section : LPCSTR optional
Fiddle::TYPE_VOIDP, # Key : LPCSTR optional
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 SetupGetLineTextA(
Context: *mut INFCONTEXT, // INFCONTEXT* optional
InfHandle: *mut (), // void* optional
Section: *const u8, // LPCSTR optional
Key: *const u8, // LPCSTR optional
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 SetupGetLineTextA(IntPtr Context, IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string Section, [MarshalAs(UnmanagedType.LPStr)] string Key, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder ReturnBuffer, uint ReturnBufferSize, IntPtr RequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupGetLineTextA' -Namespace Win32 -PassThru
# $api::SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)#uselib "SETUPAPI.dll"
#func global SetupGetLineTextA "SetupGetLineTextA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupGetLineTextA varptr(Context), InfHandle, Section, Key, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize) ; 戻り値は stat
; Context : INFCONTEXT* optional -> "sptr"
; InfHandle : void* optional -> "sptr"
; Section : LPCSTR optional -> "sptr"
; Key : LPCSTR optional -> "sptr"
; ReturnBuffer : LPSTR optional, out -> "sptr"
; ReturnBufferSize : DWORD -> "sptr"
; RequiredSize : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextA "SetupGetLineTextA" var, sptr, str, str, var, int, var ; res = SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize) ; Context : INFCONTEXT* optional -> "var" ; InfHandle : void* optional -> "sptr" ; Section : LPCSTR optional -> "str" ; Key : LPCSTR optional -> "str" ; ReturnBuffer : LPSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextA "SetupGetLineTextA" sptr, sptr, str, str, sptr, int, sptr ; res = SetupGetLineTextA(varptr(Context), InfHandle, Section, Key, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize)) ; Context : INFCONTEXT* optional -> "sptr" ; InfHandle : void* optional -> "sptr" ; Section : LPCSTR optional -> "str" ; Key : LPCSTR optional -> "str" ; ReturnBuffer : LPSTR optional, out -> "sptr" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupGetLineTextA(INFCONTEXT* Context, void* InfHandle, LPCSTR Section, LPCSTR Key, LPSTR ReturnBuffer, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextA "SetupGetLineTextA" var, intptr, str, str, var, int, var ; res = SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize) ; Context : INFCONTEXT* optional -> "var" ; InfHandle : void* optional -> "intptr" ; Section : LPCSTR optional -> "str" ; Key : LPCSTR optional -> "str" ; ReturnBuffer : LPSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupGetLineTextA(INFCONTEXT* Context, void* InfHandle, LPCSTR Section, LPCSTR Key, LPSTR ReturnBuffer, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextA "SetupGetLineTextA" intptr, intptr, str, str, intptr, int, intptr ; res = SetupGetLineTextA(varptr(Context), InfHandle, Section, Key, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize)) ; Context : INFCONTEXT* optional -> "intptr" ; InfHandle : void* optional -> "intptr" ; Section : LPCSTR optional -> "str" ; Key : LPCSTR optional -> "str" ; 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")
procSetupGetLineTextA = setupapi.NewProc("SetupGetLineTextA")
)
// Context (INFCONTEXT* optional), InfHandle (void* optional), Section (LPCSTR optional), Key (LPCSTR optional), ReturnBuffer (LPSTR optional, out), ReturnBufferSize (DWORD), RequiredSize (DWORD* optional, out)
r1, _, err := procSetupGetLineTextA.Call(
uintptr(Context),
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Section))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Key))),
uintptr(ReturnBuffer),
uintptr(ReturnBufferSize),
uintptr(RequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupGetLineTextA(
Context: Pointer; // INFCONTEXT* optional
InfHandle: Pointer; // void* optional
Section: PAnsiChar; // LPCSTR optional
Key: PAnsiChar; // LPCSTR optional
ReturnBuffer: PAnsiChar; // LPSTR optional, out
ReturnBufferSize: DWORD; // DWORD
RequiredSize: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupGetLineTextA';result := DllCall("SETUPAPI\SetupGetLineTextA"
, "Ptr", Context ; INFCONTEXT* optional
, "Ptr", InfHandle ; void* optional
, "AStr", Section ; LPCSTR optional
, "AStr", Key ; LPCSTR optional
, "Ptr", ReturnBuffer ; LPSTR optional, out
, "UInt", ReturnBufferSize ; DWORD
, "Ptr", RequiredSize ; DWORD* optional, out
, "Int") ; return: BOOL●SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize) = DLL("SETUPAPI.dll", "bool SetupGetLineTextA(void*, void*, char*, char*, char*, dword, void*)")
# 呼び出し: SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
# Context : INFCONTEXT* optional -> "void*"
# InfHandle : void* optional -> "void*"
# Section : LPCSTR optional -> "char*"
# Key : LPCSTR optional -> "char*"
# ReturnBuffer : LPSTR optional, out -> "char*"
# ReturnBufferSize : DWORD -> "dword"
# RequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。