ホーム › 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 | 対象行を示すINFCONTEXT構造体へのポインタ。NULLの場合はInfHandle/Section/Keyで指定する。 |
| InfHandle | void* | inoptional | ContextがNULLのとき使う開いているINFハンドル。 |
| Section | LPCSTR | inoptional | ContextがNULLのとき使うセクション名(ANSI)。 |
| Key | LPCSTR | inoptional | ContextがNULLのとき使うキー名(ANSI)。 |
| ReturnBuffer | LPSTR | outoptional | 行のテキスト全体を受け取る文字列バッファ(ANSI)。NULLでサイズ取得のみ可。 |
| ReturnBufferSize | DWORD | in | ReturnBufferのサイズ(文字数)。 |
| RequiredSize | DWORD* | outoptional | 必要なバッファサイズを受け取る出力ポインタ。NULL可。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。const std = @import("std");
extern "setupapi" fn SetupGetLineTextA(
Context: [*c]INFCONTEXT, // INFCONTEXT* optional
InfHandle: ?*anyopaque, // void* optional
Section: [*c]const u8, // LPCSTR optional
Key: [*c]const u8, // LPCSTR optional
ReturnBuffer: [*c]u8, // LPSTR optional, out
ReturnBufferSize: u32, // DWORD
RequiredSize: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc SetupGetLineTextA(
Context: ptr INFCONTEXT, # INFCONTEXT* optional
InfHandle: pointer, # void* optional
Section: cstring, # LPCSTR optional
Key: cstring, # LPCSTR optional
ReturnBuffer: ptr char, # LPSTR optional, out
ReturnBufferSize: uint32, # DWORD
RequiredSize: ptr uint32 # DWORD* optional, out
): int32 {.importc: "SetupGetLineTextA", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupGetLineTextA(
INFCONTEXT* Context, // INFCONTEXT* optional
void* InfHandle, // void* optional
const(char)* Section, // LPCSTR optional
const(char)* Key, // LPCSTR optional
char* ReturnBuffer, // LPSTR optional, out
uint ReturnBufferSize, // DWORD
uint* RequiredSize // DWORD* optional, out
);ccall((:SetupGetLineTextA, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{INFCONTEXT}, Ptr{Cvoid}, Cstring, Cstring, Ptr{UInt8}, UInt32, Ptr{UInt32}),
Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
# Context : INFCONTEXT* optional -> Ptr{INFCONTEXT}
# InfHandle : void* optional -> Ptr{Cvoid}
# Section : LPCSTR optional -> Cstring
# Key : LPCSTR optional -> Cstring
# ReturnBuffer : LPSTR optional, out -> Ptr{UInt8}
# ReturnBufferSize : DWORD -> UInt32
# RequiredSize : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupGetLineTextA(
void* Context,
void* InfHandle,
const char* Section,
const char* Key,
char* ReturnBuffer,
uint32_t ReturnBufferSize,
uint32_t* RequiredSize);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
-- Context : INFCONTEXT* optional
-- InfHandle : void* optional
-- Section : LPCSTR optional
-- Key : LPCSTR optional
-- ReturnBuffer : LPSTR optional, out
-- ReturnBufferSize : DWORD
-- RequiredSize : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupGetLineTextA = lib.func('__stdcall', 'SetupGetLineTextA', 'int32_t', ['void *', 'void *', 'str', 'str', 'char *', 'uint32_t', 'uint32_t *']);
// SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
// Context : INFCONTEXT* optional -> 'void *'
// InfHandle : void* optional -> 'void *'
// Section : LPCSTR optional -> 'str'
// Key : LPCSTR optional -> 'str'
// ReturnBuffer : LPSTR optional, out -> 'char *'
// ReturnBufferSize : DWORD -> 'uint32_t'
// RequiredSize : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupGetLineTextA: { parameters: ["pointer", "pointer", "buffer", "buffer", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
// Context : INFCONTEXT* optional -> "pointer"
// InfHandle : void* optional -> "pointer"
// Section : LPCSTR optional -> "buffer"
// Key : LPCSTR optional -> "buffer"
// ReturnBuffer : LPSTR optional, out -> "buffer"
// ReturnBufferSize : DWORD -> "u32"
// RequiredSize : DWORD* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupGetLineTextA(
void* Context,
void* InfHandle,
const char* Section,
const char* Key,
char* ReturnBuffer,
uint32_t ReturnBufferSize,
uint32_t* RequiredSize);
C, "SETUPAPI.dll");
// $ffi->SetupGetLineTextA(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize);
// Context : INFCONTEXT* optional
// InfHandle : void* optional
// Section : LPCSTR optional
// Key : LPCSTR optional
// ReturnBuffer : LPSTR optional, out
// ReturnBufferSize : DWORD
// RequiredSize : DWORD* optional, out
// 構造体/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 SetupGetLineTextA(
Pointer Context, // INFCONTEXT* optional
Pointer InfHandle, // void* optional
String Section, // LPCSTR optional
String Key, // LPCSTR optional
byte[] ReturnBuffer, // LPSTR optional, out
int ReturnBufferSize, // DWORD
IntByReference RequiredSize // DWORD* optional, out
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupGetLineTextA = SetupGetLineTextA(
Context : INFCONTEXT*, # INFCONTEXT* optional
InfHandle : Void*, # void* optional
Section : UInt8*, # LPCSTR optional
Key : UInt8*, # LPCSTR optional
ReturnBuffer : UInt8*, # LPSTR optional, out
ReturnBufferSize : UInt32, # DWORD
RequiredSize : UInt32* # DWORD* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupGetLineTextANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Uint32, Pointer<Uint32>);
typedef SetupGetLineTextADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Uint32>);
final SetupGetLineTextA = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupGetLineTextANative, SetupGetLineTextADart>('SetupGetLineTextA');
// Context : INFCONTEXT* optional -> Pointer<Void>
// InfHandle : void* optional -> Pointer<Void>
// Section : LPCSTR optional -> Pointer<Utf8>
// Key : LPCSTR optional -> Pointer<Utf8>
// ReturnBuffer : LPSTR optional, out -> Pointer<Utf8>
// ReturnBufferSize : DWORD -> Uint32
// RequiredSize : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupGetLineTextA"
c_SetupGetLineTextA :: Ptr () -> Ptr () -> CString -> CString -> CString -> Word32 -> Ptr Word32 -> IO CInt
-- Context : INFCONTEXT* optional -> Ptr ()
-- InfHandle : void* optional -> Ptr ()
-- Section : LPCSTR optional -> CString
-- Key : LPCSTR optional -> CString
-- ReturnBuffer : LPSTR optional, out -> CString
-- ReturnBufferSize : DWORD -> Word32
-- RequiredSize : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupgetlinetexta =
foreign "SetupGetLineTextA"
((ptr void) @-> (ptr void) @-> string @-> string @-> string @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* Context : INFCONTEXT* optional -> (ptr void) *)
(* InfHandle : void* optional -> (ptr void) *)
(* Section : LPCSTR optional -> string *)
(* Key : LPCSTR optional -> string *)
(* ReturnBuffer : LPSTR optional, out -> string *)
(* ReturnBufferSize : DWORD -> uint32_t *)
(* RequiredSize : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupGetLineTextA" setup-get-line-text-a :convention :stdcall) :int32
(context :pointer) ; INFCONTEXT* optional
(inf-handle :pointer) ; void* optional
(section :string) ; LPCSTR optional
(key :string) ; LPCSTR optional
(return-buffer :pointer) ; LPSTR optional, out
(return-buffer-size :uint32) ; DWORD
(required-size :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupGetLineTextA = Win32::API::More->new('SETUPAPI',
'BOOL SetupGetLineTextA(LPVOID Context, LPVOID InfHandle, LPCSTR Section, LPCSTR Key, LPSTR ReturnBuffer, DWORD ReturnBufferSize, LPVOID RequiredSize)');
# my $ret = $SetupGetLineTextA->Call($Context, $InfHandle, $Section, $Key, $ReturnBuffer, $ReturnBufferSize, $RequiredSize);
# Context : INFCONTEXT* optional -> LPVOID
# InfHandle : void* optional -> LPVOID
# Section : LPCSTR optional -> LPCSTR
# Key : LPCSTR optional -> LPCSTR
# ReturnBuffer : LPSTR optional, out -> LPSTR
# ReturnBufferSize : DWORD -> DWORD
# RequiredSize : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SetupGetLineTextW (Unicode版) — INFの指定行またはキーのテキストを取得する(Unicode)。
使用する型