ホーム › Devices.DeviceAndDriverInstallation › SetupQueryFileLogW
SetupQueryFileLogW
関数ファイルログから指定ファイルの記録情報を取得する。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueryFileLogW(
void* FileLogHandle,
LPCWSTR LogSectionName, // optional
LPCWSTR TargetFilename,
SetupFileLogInfo DesiredInfo,
LPWSTR DataOut, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileLogHandle | void* | in | 問い合わせ対象のファイルログのハンドル。 |
| LogSectionName | LPCWSTR | inoptional | 対象エントリが属するセクション名(Unicode)。NULL可。 |
| TargetFilename | LPCWSTR | in | 情報を取得する対象のターゲットファイル名(Unicode)。 |
| DesiredInfo | SetupFileLogInfo | in | 取得する情報の種類を示すSetupFileLogInfo列挙値。 |
| DataOut | LPWSTR | outoptional | 取得した情報を受け取るバッファ(Unicode)。NULL可。 |
| ReturnBufferSize | DWORD | in | DataOutバッファの文字数サイズ。 |
| RequiredSize | DWORD* | outoptional | 必要なバッファ文字数を受け取るDWORDへのポインタ。NULL可。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueryFileLogW(
void* FileLogHandle,
LPCWSTR LogSectionName, // optional
LPCWSTR TargetFilename,
SetupFileLogInfo DesiredInfo,
LPWSTR DataOut, // optional
DWORD ReturnBufferSize,
DWORD* RequiredSize // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupQueryFileLogW(
IntPtr FileLogHandle, // void*
[MarshalAs(UnmanagedType.LPWStr)] string LogSectionName, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string TargetFilename, // LPCWSTR
int DesiredInfo, // SetupFileLogInfo
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DataOut, // LPWSTR optional, out
uint ReturnBufferSize, // DWORD
IntPtr RequiredSize // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupQueryFileLogW(
FileLogHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> LogSectionName As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> TargetFilename As String, ' LPCWSTR
DesiredInfo As Integer, ' SetupFileLogInfo
<MarshalAs(UnmanagedType.LPWStr)> DataOut As System.Text.StringBuilder, ' LPWSTR optional, out
ReturnBufferSize As UInteger, ' DWORD
RequiredSize As IntPtr ' DWORD* optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' FileLogHandle : void*
' LogSectionName : LPCWSTR optional
' TargetFilename : LPCWSTR
' DesiredInfo : SetupFileLogInfo
' DataOut : LPWSTR optional, out
' ReturnBufferSize : DWORD
' RequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupQueryFileLogW Lib "setupapi" ( _
ByVal FileLogHandle As LongPtr, _
ByVal LogSectionName As LongPtr, _
ByVal TargetFilename As LongPtr, _
ByVal DesiredInfo As Long, _
ByVal DataOut 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
SetupQueryFileLogW = ctypes.windll.setupapi.SetupQueryFileLogW
SetupQueryFileLogW.restype = wintypes.BOOL
SetupQueryFileLogW.argtypes = [
ctypes.POINTER(None), # FileLogHandle : void*
wintypes.LPCWSTR, # LogSectionName : LPCWSTR optional
wintypes.LPCWSTR, # TargetFilename : LPCWSTR
ctypes.c_int, # DesiredInfo : SetupFileLogInfo
wintypes.LPWSTR, # DataOut : 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')
SetupQueryFileLogW = Fiddle::Function.new(
lib['SetupQueryFileLogW'],
[
Fiddle::TYPE_VOIDP, # FileLogHandle : void*
Fiddle::TYPE_VOIDP, # LogSectionName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # TargetFilename : LPCWSTR
Fiddle::TYPE_INT, # DesiredInfo : SetupFileLogInfo
Fiddle::TYPE_VOIDP, # DataOut : 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 SetupQueryFileLogW(
FileLogHandle: *mut (), // void*
LogSectionName: *const u16, // LPCWSTR optional
TargetFilename: *const u16, // LPCWSTR
DesiredInfo: i32, // SetupFileLogInfo
DataOut: *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 SetupQueryFileLogW(IntPtr FileLogHandle, [MarshalAs(UnmanagedType.LPWStr)] string LogSectionName, [MarshalAs(UnmanagedType.LPWStr)] string TargetFilename, int DesiredInfo, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DataOut, uint ReturnBufferSize, IntPtr RequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueryFileLogW' -Namespace Win32 -PassThru
# $api::SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize)#uselib "SETUPAPI.dll"
#func global SetupQueryFileLogW "SetupQueryFileLogW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupQueryFileLogW FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, varptr(DataOut), ReturnBufferSize, varptr(RequiredSize) ; 戻り値は stat
; FileLogHandle : void* -> "wptr"
; LogSectionName : LPCWSTR optional -> "wptr"
; TargetFilename : LPCWSTR -> "wptr"
; DesiredInfo : SetupFileLogInfo -> "wptr"
; DataOut : LPWSTR optional, out -> "wptr"
; ReturnBufferSize : DWORD -> "wptr"
; RequiredSize : DWORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupQueryFileLogW "SetupQueryFileLogW" sptr, wstr, wstr, int, var, int, var ; res = SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize) ; FileLogHandle : void* -> "sptr" ; LogSectionName : LPCWSTR optional -> "wstr" ; TargetFilename : LPCWSTR -> "wstr" ; DesiredInfo : SetupFileLogInfo -> "int" ; DataOut : LPWSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupQueryFileLogW "SetupQueryFileLogW" sptr, wstr, wstr, int, sptr, int, sptr ; res = SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, varptr(DataOut), ReturnBufferSize, varptr(RequiredSize)) ; FileLogHandle : void* -> "sptr" ; LogSectionName : LPCWSTR optional -> "wstr" ; TargetFilename : LPCWSTR -> "wstr" ; DesiredInfo : SetupFileLogInfo -> "int" ; DataOut : LPWSTR optional, out -> "sptr" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupQueryFileLogW(void* FileLogHandle, LPCWSTR LogSectionName, LPCWSTR TargetFilename, SetupFileLogInfo DesiredInfo, LPWSTR DataOut, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupQueryFileLogW "SetupQueryFileLogW" intptr, wstr, wstr, int, var, int, var ; res = SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize) ; FileLogHandle : void* -> "intptr" ; LogSectionName : LPCWSTR optional -> "wstr" ; TargetFilename : LPCWSTR -> "wstr" ; DesiredInfo : SetupFileLogInfo -> "int" ; DataOut : LPWSTR optional, out -> "var" ; ReturnBufferSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupQueryFileLogW(void* FileLogHandle, LPCWSTR LogSectionName, LPCWSTR TargetFilename, SetupFileLogInfo DesiredInfo, LPWSTR DataOut, DWORD ReturnBufferSize, DWORD* RequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupQueryFileLogW "SetupQueryFileLogW" intptr, wstr, wstr, int, intptr, int, intptr ; res = SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, varptr(DataOut), ReturnBufferSize, varptr(RequiredSize)) ; FileLogHandle : void* -> "intptr" ; LogSectionName : LPCWSTR optional -> "wstr" ; TargetFilename : LPCWSTR -> "wstr" ; DesiredInfo : SetupFileLogInfo -> "int" ; DataOut : 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")
procSetupQueryFileLogW = setupapi.NewProc("SetupQueryFileLogW")
)
// FileLogHandle (void*), LogSectionName (LPCWSTR optional), TargetFilename (LPCWSTR), DesiredInfo (SetupFileLogInfo), DataOut (LPWSTR optional, out), ReturnBufferSize (DWORD), RequiredSize (DWORD* optional, out)
r1, _, err := procSetupQueryFileLogW.Call(
uintptr(FileLogHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(LogSectionName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetFilename))),
uintptr(DesiredInfo),
uintptr(DataOut),
uintptr(ReturnBufferSize),
uintptr(RequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupQueryFileLogW(
FileLogHandle: Pointer; // void*
LogSectionName: PWideChar; // LPCWSTR optional
TargetFilename: PWideChar; // LPCWSTR
DesiredInfo: Integer; // SetupFileLogInfo
DataOut: PWideChar; // LPWSTR optional, out
ReturnBufferSize: DWORD; // DWORD
RequiredSize: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueryFileLogW';result := DllCall("SETUPAPI\SetupQueryFileLogW"
, "Ptr", FileLogHandle ; void*
, "WStr", LogSectionName ; LPCWSTR optional
, "WStr", TargetFilename ; LPCWSTR
, "Int", DesiredInfo ; SetupFileLogInfo
, "Ptr", DataOut ; LPWSTR optional, out
, "UInt", ReturnBufferSize ; DWORD
, "Ptr", RequiredSize ; DWORD* optional, out
, "Int") ; return: BOOL●SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize) = DLL("SETUPAPI.dll", "bool SetupQueryFileLogW(void*, char*, char*, int, char*, dword, void*)")
# 呼び出し: SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize)
# FileLogHandle : void* -> "void*"
# LogSectionName : LPCWSTR optional -> "char*"
# TargetFilename : LPCWSTR -> "char*"
# DesiredInfo : SetupFileLogInfo -> "int"
# DataOut : 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 SetupQueryFileLogW(
FileLogHandle: ?*anyopaque, // void*
LogSectionName: [*c]const u16, // LPCWSTR optional
TargetFilename: [*c]const u16, // LPCWSTR
DesiredInfo: i32, // SetupFileLogInfo
DataOut: [*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 SetupQueryFileLogW(
FileLogHandle: pointer, # void*
LogSectionName: WideCString, # LPCWSTR optional
TargetFilename: WideCString, # LPCWSTR
DesiredInfo: int32, # SetupFileLogInfo
DataOut: ptr uint16, # LPWSTR optional, out
ReturnBufferSize: uint32, # DWORD
RequiredSize: ptr uint32 # DWORD* optional, out
): int32 {.importc: "SetupQueryFileLogW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupQueryFileLogW(
void* FileLogHandle, // void*
const(wchar)* LogSectionName, // LPCWSTR optional
const(wchar)* TargetFilename, // LPCWSTR
int DesiredInfo, // SetupFileLogInfo
wchar* DataOut, // LPWSTR optional, out
uint ReturnBufferSize, // DWORD
uint* RequiredSize // DWORD* optional, out
);ccall((:SetupQueryFileLogW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Cwstring, Int32, Ptr{UInt16}, UInt32, Ptr{UInt32}),
FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize)
# FileLogHandle : void* -> Ptr{Cvoid}
# LogSectionName : LPCWSTR optional -> Cwstring
# TargetFilename : LPCWSTR -> Cwstring
# DesiredInfo : SetupFileLogInfo -> Int32
# DataOut : 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 SetupQueryFileLogW(
void* FileLogHandle,
const uint16_t* LogSectionName,
const uint16_t* TargetFilename,
int32_t DesiredInfo,
uint16_t* DataOut,
uint32_t ReturnBufferSize,
uint32_t* RequiredSize);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize)
-- FileLogHandle : void*
-- LogSectionName : LPCWSTR optional
-- TargetFilename : LPCWSTR
-- DesiredInfo : SetupFileLogInfo
-- DataOut : 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 SetupQueryFileLogW = lib.func('__stdcall', 'SetupQueryFileLogW', 'int32_t', ['void *', 'str16', 'str16', 'int32_t', 'uint16_t *', 'uint32_t', 'uint32_t *']);
// SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize)
// FileLogHandle : void* -> 'void *'
// LogSectionName : LPCWSTR optional -> 'str16'
// TargetFilename : LPCWSTR -> 'str16'
// DesiredInfo : SetupFileLogInfo -> 'int32_t'
// DataOut : 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", {
SetupQueryFileLogW: { parameters: ["pointer", "buffer", "buffer", "i32", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize)
// FileLogHandle : void* -> "pointer"
// LogSectionName : LPCWSTR optional -> "buffer"
// TargetFilename : LPCWSTR -> "buffer"
// DesiredInfo : SetupFileLogInfo -> "i32"
// DataOut : 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 SetupQueryFileLogW(
void* FileLogHandle,
const uint16_t* LogSectionName,
const uint16_t* TargetFilename,
int32_t DesiredInfo,
uint16_t* DataOut,
uint32_t ReturnBufferSize,
uint32_t* RequiredSize);
C, "SETUPAPI.dll");
// $ffi->SetupQueryFileLogW(FileLogHandle, LogSectionName, TargetFilename, DesiredInfo, DataOut, ReturnBufferSize, RequiredSize);
// FileLogHandle : void*
// LogSectionName : LPCWSTR optional
// TargetFilename : LPCWSTR
// DesiredInfo : SetupFileLogInfo
// DataOut : 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 SetupQueryFileLogW(
Pointer FileLogHandle, // void*
WString LogSectionName, // LPCWSTR optional
WString TargetFilename, // LPCWSTR
int DesiredInfo, // SetupFileLogInfo
char[] DataOut, // LPWSTR optional, out
int ReturnBufferSize, // DWORD
IntByReference RequiredSize // DWORD* optional, out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupQueryFileLogW = SetupQueryFileLogW(
FileLogHandle : Void*, # void*
LogSectionName : UInt16*, # LPCWSTR optional
TargetFilename : UInt16*, # LPCWSTR
DesiredInfo : Int32, # SetupFileLogInfo
DataOut : 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 SetupQueryFileLogWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Int32, Pointer<Utf16>, Uint32, Pointer<Uint32>);
typedef SetupQueryFileLogWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Utf16>, int, Pointer<Uint32>);
final SetupQueryFileLogW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupQueryFileLogWNative, SetupQueryFileLogWDart>('SetupQueryFileLogW');
// FileLogHandle : void* -> Pointer<Void>
// LogSectionName : LPCWSTR optional -> Pointer<Utf16>
// TargetFilename : LPCWSTR -> Pointer<Utf16>
// DesiredInfo : SetupFileLogInfo -> Int32
// DataOut : LPWSTR optional, out -> Pointer<Utf16>
// ReturnBufferSize : DWORD -> Uint32
// RequiredSize : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupQueryFileLogW(
FileLogHandle: Pointer; // void*
LogSectionName: PWideChar; // LPCWSTR optional
TargetFilename: PWideChar; // LPCWSTR
DesiredInfo: Integer; // SetupFileLogInfo
DataOut: PWideChar; // LPWSTR optional, out
ReturnBufferSize: DWORD; // DWORD
RequiredSize: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueryFileLogW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupQueryFileLogW"
c_SetupQueryFileLogW :: Ptr () -> CWString -> CWString -> Int32 -> CWString -> Word32 -> Ptr Word32 -> IO CInt
-- FileLogHandle : void* -> Ptr ()
-- LogSectionName : LPCWSTR optional -> CWString
-- TargetFilename : LPCWSTR -> CWString
-- DesiredInfo : SetupFileLogInfo -> Int32
-- DataOut : 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 setupqueryfilelogw =
foreign "SetupQueryFileLogW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* FileLogHandle : void* -> (ptr void) *)
(* LogSectionName : LPCWSTR optional -> (ptr uint16_t) *)
(* TargetFilename : LPCWSTR -> (ptr uint16_t) *)
(* DesiredInfo : SetupFileLogInfo -> int32_t *)
(* DataOut : 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 ("SetupQueryFileLogW" setup-query-file-log-w :convention :stdcall) :int32
(file-log-handle :pointer) ; void*
(log-section-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(target-filename (:string :encoding :utf-16le)) ; LPCWSTR
(desired-info :int32) ; SetupFileLogInfo
(data-out :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 $SetupQueryFileLogW = Win32::API::More->new('SETUPAPI',
'BOOL SetupQueryFileLogW(LPVOID FileLogHandle, LPCWSTR LogSectionName, LPCWSTR TargetFilename, int DesiredInfo, LPWSTR DataOut, DWORD ReturnBufferSize, LPVOID RequiredSize)');
# my $ret = $SetupQueryFileLogW->Call($FileLogHandle, $LogSectionName, $TargetFilename, $DesiredInfo, $DataOut, $ReturnBufferSize, $RequiredSize);
# FileLogHandle : void* -> LPVOID
# LogSectionName : LPCWSTR optional -> LPCWSTR
# TargetFilename : LPCWSTR -> LPCWSTR
# DesiredInfo : SetupFileLogInfo -> int
# DataOut : 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 SetupQueryFileLogA (ANSI版) — ファイルログから指定ファイルの記録情報を取得する。
使用する型