Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupQueryFileLogW

SetupQueryFileLogW

関数
ファイルログから指定ファイルの記録情報を取得する。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// 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
);

パラメーター

名前方向
FileLogHandlevoid*in
LogSectionNameLPCWSTRinoptional
TargetFilenameLPCWSTRin
DesiredInfoSetupFileLogInfoin
DataOutLPWSTRoutoptional
ReturnBufferSizeDWORDin
RequiredSizeDWORD*outoptional

戻り値の型: 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 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // BOOL
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';
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 版の利用を推奨。