ホーム › Devices.DeviceAndDriverInstallation › SetupGetLineTextW
SetupGetLineTextW
関数INFの指定行またはキーのテキストを取得する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupGetLineTextW(
INFCONTEXT* Context, // optional
void* InfHandle, // optional
LPCWSTR Section, // optional
LPCWSTR Key, // optional
LPWSTR ReturnBuffer, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Context | INFCONTEXT* | inoptional | 対象行を示すINFCONTEXT構造体へのポインタ。NULLの場合はInfHandle/Section/Keyで指定する。 |
| InfHandle | void* | inoptional | ContextがNULLのとき使う開いているINFハンドル。 |
| Section | LPCWSTR | inoptional | ContextがNULLのとき使うセクション名(Unicode)。 |
| Key | LPCWSTR | inoptional | ContextがNULLのとき使うキー名(Unicode)。 |
| ReturnBuffer | LPWSTR | outoptional | 行のテキスト全体を受け取る文字列バッファ(Unicode)。NULLでサイズ取得のみ可。 |
| ReturnBufferSize | DWORD | in | ReturnBufferのサイズ(文字数)。 |
| RequiredSize | DWORD* | outoptional | 必要なバッファサイズを受け取る出力ポインタ。NULL可。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupGetLineTextW(
INFCONTEXT* Context, // optional
void* InfHandle, // optional
LPCWSTR Section, // optional
LPCWSTR Key, // optional
LPWSTR ReturnBuffer, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupGetLineTextW(
IntPtr Context, // INFCONTEXT* optional
IntPtr InfHandle, // void* optional
[MarshalAs(UnmanagedType.LPWStr)] string Section, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string Key, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ReturnBuffer, // LPWSTR optional, out
uint ReturnBufferSize, // DWORD
IntPtr RequiredSize // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupGetLineTextW(
Context As IntPtr, ' INFCONTEXT* optional
InfHandle As IntPtr, ' void* optional
<MarshalAs(UnmanagedType.LPWStr)> Section As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> Key As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> ReturnBuffer As System.Text.StringBuilder, ' LPWSTR 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 : LPCWSTR optional
' Key : LPCWSTR optional
' ReturnBuffer : LPWSTR optional, out
' ReturnBufferSize : DWORD
' RequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupGetLineTextW Lib "setupapi" ( _
ByVal Context As LongPtr, _
ByVal InfHandle As LongPtr, _
ByVal Section As LongPtr, _
ByVal Key As LongPtr, _
ByVal ReturnBuffer As LongPtr, _
ByVal ReturnBufferSize As Long, _
ByVal RequiredSize 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
SetupGetLineTextW = ctypes.windll.setupapi.SetupGetLineTextW
SetupGetLineTextW.restype = wintypes.BOOL
SetupGetLineTextW.argtypes = [
ctypes.c_void_p, # Context : INFCONTEXT* optional
ctypes.POINTER(None), # InfHandle : void* optional
wintypes.LPCWSTR, # Section : LPCWSTR optional
wintypes.LPCWSTR, # Key : LPCWSTR optional
wintypes.LPWSTR, # ReturnBuffer : LPWSTR 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')
SetupGetLineTextW = Fiddle::Function.new(
lib['SetupGetLineTextW'],
[
Fiddle::TYPE_VOIDP, # Context : INFCONTEXT* optional
Fiddle::TYPE_VOIDP, # InfHandle : void* optional
Fiddle::TYPE_VOIDP, # Section : LPCWSTR optional
Fiddle::TYPE_VOIDP, # Key : LPCWSTR optional
Fiddle::TYPE_VOIDP, # ReturnBuffer : LPWSTR optional, out
-Fiddle::TYPE_INT, # ReturnBufferSize : DWORD
Fiddle::TYPE_VOIDP, # RequiredSize : DWORD* optional, out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupGetLineTextW(
Context: *mut INFCONTEXT, // INFCONTEXT* optional
InfHandle: *mut (), // void* optional
Section: *const u16, // LPCWSTR optional
Key: *const u16, // LPCWSTR optional
ReturnBuffer: *mut u16, // LPWSTR 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.Unicode, SetLastError = true)]
public static extern bool SetupGetLineTextW(IntPtr Context, IntPtr InfHandle, [MarshalAs(UnmanagedType.LPWStr)] string Section, [MarshalAs(UnmanagedType.LPWStr)] string Key, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ReturnBuffer, uint ReturnBufferSize, IntPtr RequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupGetLineTextW' -Namespace Win32 -PassThru
# $api::SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)#uselib "SETUPAPI.dll"
#func global SetupGetLineTextW "SetupGetLineTextW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupGetLineTextW varptr(Context), InfHandle, Section, Key, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize) ; 戻り値は stat
; Context : INFCONTEXT* optional -> "wptr"
; InfHandle : void* optional -> "wptr"
; Section : LPCWSTR optional -> "wptr"
; Key : LPCWSTR optional -> "wptr"
; ReturnBuffer : LPWSTR optional, out -> "wptr"
; ReturnBufferSize : DWORD -> "wptr"
; RequiredSize : DWORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextW "SetupGetLineTextW" var, sptr, wstr, wstr, var, int, var ; res = SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize) ; Context : INFCONTEXT* optional -> "var" ; InfHandle : void* optional -> "sptr" ; Section : LPCWSTR optional -> "wstr" ; Key : LPCWSTR optional -> "wstr" ; ReturnBuffer : LPWSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextW "SetupGetLineTextW" sptr, sptr, wstr, wstr, sptr, int, sptr ; res = SetupGetLineTextW(varptr(Context), InfHandle, Section, Key, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize)) ; Context : INFCONTEXT* optional -> "sptr" ; InfHandle : void* optional -> "sptr" ; Section : LPCWSTR optional -> "wstr" ; Key : LPCWSTR optional -> "wstr" ; ReturnBuffer : LPWSTR optional, out -> "sptr" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupGetLineTextW(INFCONTEXT* Context, void* InfHandle, LPCWSTR Section, LPCWSTR Key, LPWSTR ReturnBuffer, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextW "SetupGetLineTextW" var, intptr, wstr, wstr, var, int, var ; res = SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize) ; Context : INFCONTEXT* optional -> "var" ; InfHandle : void* optional -> "intptr" ; Section : LPCWSTR optional -> "wstr" ; Key : LPCWSTR optional -> "wstr" ; ReturnBuffer : LPWSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupGetLineTextW(INFCONTEXT* Context, void* InfHandle, LPCWSTR Section, LPCWSTR Key, LPWSTR ReturnBuffer, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupGetLineTextW "SetupGetLineTextW" intptr, intptr, wstr, wstr, intptr, int, intptr ; res = SetupGetLineTextW(varptr(Context), InfHandle, Section, Key, varptr(ReturnBuffer), ReturnBufferSize, varptr(RequiredSize)) ; Context : INFCONTEXT* optional -> "intptr" ; InfHandle : void* optional -> "intptr" ; Section : LPCWSTR optional -> "wstr" ; Key : LPCWSTR optional -> "wstr" ; ReturnBuffer : LPWSTR 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")
procSetupGetLineTextW = setupapi.NewProc("SetupGetLineTextW")
)
// Context (INFCONTEXT* optional), InfHandle (void* optional), Section (LPCWSTR optional), Key (LPCWSTR optional), ReturnBuffer (LPWSTR optional, out), ReturnBufferSize (DWORD), RequiredSize (DWORD* optional, out)
r1, _, err := procSetupGetLineTextW.Call(
uintptr(Context),
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Section))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Key))),
uintptr(ReturnBuffer),
uintptr(ReturnBufferSize),
uintptr(RequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupGetLineTextW(
Context: Pointer; // INFCONTEXT* optional
InfHandle: Pointer; // void* optional
Section: PWideChar; // LPCWSTR optional
Key: PWideChar; // LPCWSTR optional
ReturnBuffer: PWideChar; // LPWSTR optional, out
ReturnBufferSize: DWORD; // DWORD
RequiredSize: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupGetLineTextW';result := DllCall("SETUPAPI\SetupGetLineTextW"
, "Ptr", Context ; INFCONTEXT* optional
, "Ptr", InfHandle ; void* optional
, "WStr", Section ; LPCWSTR optional
, "WStr", Key ; LPCWSTR optional
, "Ptr", ReturnBuffer ; LPWSTR optional, out
, "UInt", ReturnBufferSize ; DWORD
, "Ptr", RequiredSize ; DWORD* optional, out
, "Int") ; return: BOOL●SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize) = DLL("SETUPAPI.dll", "bool SetupGetLineTextW(void*, void*, char*, char*, char*, dword, void*)")
# 呼び出し: SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
# Context : INFCONTEXT* optional -> "void*"
# InfHandle : void* optional -> "void*"
# Section : LPCWSTR optional -> "char*"
# Key : LPCWSTR optional -> "char*"
# ReturnBuffer : LPWSTR optional, out -> "char*"
# ReturnBufferSize : DWORD -> "dword"
# RequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupGetLineTextW(
Context: [*c]INFCONTEXT, // INFCONTEXT* optional
InfHandle: ?*anyopaque, // void* optional
Section: [*c]const u16, // LPCWSTR optional
Key: [*c]const u16, // LPCWSTR optional
ReturnBuffer: [*c]u16, // LPWSTR optional, out
ReturnBufferSize: u32, // DWORD
RequiredSize: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupGetLineTextW(
Context: ptr INFCONTEXT, # INFCONTEXT* optional
InfHandle: pointer, # void* optional
Section: WideCString, # LPCWSTR optional
Key: WideCString, # LPCWSTR optional
ReturnBuffer: ptr uint16, # LPWSTR optional, out
ReturnBufferSize: uint32, # DWORD
RequiredSize: ptr uint32 # DWORD* optional, out
): int32 {.importc: "SetupGetLineTextW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupGetLineTextW(
INFCONTEXT* Context, // INFCONTEXT* optional
void* InfHandle, // void* optional
const(wchar)* Section, // LPCWSTR optional
const(wchar)* Key, // LPCWSTR optional
wchar* ReturnBuffer, // LPWSTR optional, out
uint ReturnBufferSize, // DWORD
uint* RequiredSize // DWORD* optional, out
);ccall((:SetupGetLineTextW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{INFCONTEXT}, Ptr{Cvoid}, Cwstring, Cwstring, Ptr{UInt16}, UInt32, Ptr{UInt32}),
Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
# Context : INFCONTEXT* optional -> Ptr{INFCONTEXT}
# InfHandle : void* optional -> Ptr{Cvoid}
# Section : LPCWSTR optional -> Cwstring
# Key : LPCWSTR optional -> Cwstring
# ReturnBuffer : LPWSTR optional, out -> Ptr{UInt16}
# ReturnBufferSize : DWORD -> UInt32
# RequiredSize : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupGetLineTextW(
void* Context,
void* InfHandle,
const uint16_t* Section,
const uint16_t* Key,
uint16_t* ReturnBuffer,
uint32_t ReturnBufferSize,
uint32_t* RequiredSize);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
-- Context : INFCONTEXT* optional
-- InfHandle : void* optional
-- Section : LPCWSTR optional
-- Key : LPCWSTR optional
-- ReturnBuffer : LPWSTR optional, out
-- ReturnBufferSize : DWORD
-- RequiredSize : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupGetLineTextW = lib.func('__stdcall', 'SetupGetLineTextW', 'int32_t', ['void *', 'void *', 'str16', 'str16', 'uint16_t *', 'uint32_t', 'uint32_t *']);
// SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
// Context : INFCONTEXT* optional -> 'void *'
// InfHandle : void* optional -> 'void *'
// Section : LPCWSTR optional -> 'str16'
// Key : LPCWSTR optional -> 'str16'
// ReturnBuffer : LPWSTR optional, out -> 'uint16_t *'
// ReturnBufferSize : DWORD -> 'uint32_t'
// RequiredSize : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupGetLineTextW: { parameters: ["pointer", "pointer", "buffer", "buffer", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize)
// Context : INFCONTEXT* optional -> "pointer"
// InfHandle : void* optional -> "pointer"
// Section : LPCWSTR optional -> "buffer"
// Key : LPCWSTR optional -> "buffer"
// ReturnBuffer : LPWSTR optional, out -> "buffer"
// ReturnBufferSize : DWORD -> "u32"
// RequiredSize : DWORD* optional, out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupGetLineTextW(
void* Context,
void* InfHandle,
const uint16_t* Section,
const uint16_t* Key,
uint16_t* ReturnBuffer,
uint32_t ReturnBufferSize,
uint32_t* RequiredSize);
C, "SETUPAPI.dll");
// $ffi->SetupGetLineTextW(Context, InfHandle, Section, Key, ReturnBuffer, ReturnBufferSize, RequiredSize);
// Context : INFCONTEXT* optional
// InfHandle : void* optional
// Section : LPCWSTR optional
// Key : LPCWSTR optional
// ReturnBuffer : LPWSTR 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.UNICODE_OPTIONS);
boolean SetupGetLineTextW(
Pointer Context, // INFCONTEXT* optional
Pointer InfHandle, // void* optional
WString Section, // LPCWSTR optional
WString Key, // LPCWSTR optional
char[] ReturnBuffer, // LPWSTR optional, out
int ReturnBufferSize, // DWORD
IntByReference RequiredSize // DWORD* optional, out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupGetLineTextW = SetupGetLineTextW(
Context : INFCONTEXT*, # INFCONTEXT* optional
InfHandle : Void*, # void* optional
Section : UInt16*, # LPCWSTR optional
Key : UInt16*, # LPCWSTR optional
ReturnBuffer : UInt16*, # LPWSTR 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 SetupGetLineTextWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Uint32>);
typedef SetupGetLineTextWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Uint32>);
final SetupGetLineTextW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupGetLineTextWNative, SetupGetLineTextWDart>('SetupGetLineTextW');
// Context : INFCONTEXT* optional -> Pointer<Void>
// InfHandle : void* optional -> Pointer<Void>
// Section : LPCWSTR optional -> Pointer<Utf16>
// Key : LPCWSTR optional -> Pointer<Utf16>
// ReturnBuffer : LPWSTR optional, out -> Pointer<Utf16>
// ReturnBufferSize : DWORD -> Uint32
// RequiredSize : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupGetLineTextW(
Context: Pointer; // INFCONTEXT* optional
InfHandle: Pointer; // void* optional
Section: PWideChar; // LPCWSTR optional
Key: PWideChar; // LPCWSTR optional
ReturnBuffer: PWideChar; // LPWSTR optional, out
ReturnBufferSize: DWORD; // DWORD
RequiredSize: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupGetLineTextW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupGetLineTextW"
c_SetupGetLineTextW :: Ptr () -> Ptr () -> CWString -> CWString -> CWString -> Word32 -> Ptr Word32 -> IO CInt
-- Context : INFCONTEXT* optional -> Ptr ()
-- InfHandle : void* optional -> Ptr ()
-- Section : LPCWSTR optional -> CWString
-- Key : LPCWSTR optional -> CWString
-- ReturnBuffer : LPWSTR optional, out -> CWString
-- ReturnBufferSize : DWORD -> Word32
-- RequiredSize : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupgetlinetextw =
foreign "SetupGetLineTextW"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* Context : INFCONTEXT* optional -> (ptr void) *)
(* InfHandle : void* optional -> (ptr void) *)
(* Section : LPCWSTR optional -> (ptr uint16_t) *)
(* Key : LPCWSTR optional -> (ptr uint16_t) *)
(* ReturnBuffer : LPWSTR optional, out -> (ptr uint16_t) *)
(* 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 ("SetupGetLineTextW" setup-get-line-text-w :convention :stdcall) :int32
(context :pointer) ; INFCONTEXT* optional
(inf-handle :pointer) ; void* optional
(section (:string :encoding :utf-16le)) ; LPCWSTR optional
(key (:string :encoding :utf-16le)) ; LPCWSTR optional
(return-buffer :pointer) ; LPWSTR 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 $SetupGetLineTextW = Win32::API::More->new('SETUPAPI',
'BOOL SetupGetLineTextW(LPVOID Context, LPVOID InfHandle, LPCWSTR Section, LPCWSTR Key, LPWSTR ReturnBuffer, DWORD ReturnBufferSize, LPVOID RequiredSize)');
# my $ret = $SetupGetLineTextW->Call($Context, $InfHandle, $Section, $Key, $ReturnBuffer, $ReturnBufferSize, $RequiredSize);
# Context : INFCONTEXT* optional -> LPVOID
# InfHandle : void* optional -> LPVOID
# Section : LPCWSTR optional -> LPCWSTR
# Key : LPCWSTR optional -> LPCWSTR
# ReturnBuffer : LPWSTR optional, out -> LPWSTR
# ReturnBufferSize : DWORD -> DWORD
# RequiredSize : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupGetLineTextA (ANSI版) — INFの指定行またはキーのテキストを取得する(ANSI)。
使用する型