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

SetupLogFileW

関数
コピーしたファイルの情報をセットアップファイルログに記録する。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupLogFileW(
    void* FileLogHandle,
    LPCWSTR LogSectionName,   // optional
    LPCWSTR SourceFilename,
    LPCWSTR TargetFilename,
    DWORD Checksum,
    LPCWSTR DiskTagfile,   // optional
    LPCWSTR DiskDescription,   // optional
    LPCWSTR OtherInfo,   // optional
    DWORD Flags
);

パラメーター

名前方向
FileLogHandlevoid*in
LogSectionNameLPCWSTRinoptional
SourceFilenameLPCWSTRin
TargetFilenameLPCWSTRin
ChecksumDWORDin
DiskTagfileLPCWSTRinoptional
DiskDescriptionLPCWSTRinoptional
OtherInfoLPCWSTRinoptional
FlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupLogFileW(
    void* FileLogHandle,
    LPCWSTR LogSectionName,   // optional
    LPCWSTR SourceFilename,
    LPCWSTR TargetFilename,
    DWORD Checksum,
    LPCWSTR DiskTagfile,   // optional
    LPCWSTR DiskDescription,   // optional
    LPCWSTR OtherInfo,   // optional
    DWORD Flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupLogFileW(
    IntPtr FileLogHandle,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string LogSectionName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string SourceFilename,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string TargetFilename,   // LPCWSTR
    uint Checksum,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string DiskTagfile,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string DiskDescription,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string OtherInfo,   // LPCWSTR optional
    uint Flags   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupLogFileW(
    FileLogHandle As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> LogSectionName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> SourceFilename As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> TargetFilename As String,   ' LPCWSTR
    Checksum As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> DiskTagfile As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> DiskDescription As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> OtherInfo As String,   ' LPCWSTR optional
    Flags As UInteger   ' DWORD
) As Boolean
End Function
' FileLogHandle : void*
' LogSectionName : LPCWSTR optional
' SourceFilename : LPCWSTR
' TargetFilename : LPCWSTR
' Checksum : DWORD
' DiskTagfile : LPCWSTR optional
' DiskDescription : LPCWSTR optional
' OtherInfo : LPCWSTR optional
' Flags : DWORD
Declare PtrSafe Function SetupLogFileW Lib "setupapi" ( _
    ByVal FileLogHandle As LongPtr, _
    ByVal LogSectionName As LongPtr, _
    ByVal SourceFilename As LongPtr, _
    ByVal TargetFilename As LongPtr, _
    ByVal Checksum As Long, _
    ByVal DiskTagfile As LongPtr, _
    ByVal DiskDescription As LongPtr, _
    ByVal OtherInfo As LongPtr, _
    ByVal Flags As Long) 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

SetupLogFileW = ctypes.windll.setupapi.SetupLogFileW
SetupLogFileW.restype = wintypes.BOOL
SetupLogFileW.argtypes = [
    ctypes.POINTER(None),  # FileLogHandle : void*
    wintypes.LPCWSTR,  # LogSectionName : LPCWSTR optional
    wintypes.LPCWSTR,  # SourceFilename : LPCWSTR
    wintypes.LPCWSTR,  # TargetFilename : LPCWSTR
    wintypes.DWORD,  # Checksum : DWORD
    wintypes.LPCWSTR,  # DiskTagfile : LPCWSTR optional
    wintypes.LPCWSTR,  # DiskDescription : LPCWSTR optional
    wintypes.LPCWSTR,  # OtherInfo : LPCWSTR optional
    wintypes.DWORD,  # Flags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupLogFileW = Fiddle::Function.new(
  lib['SetupLogFileW'],
  [
    Fiddle::TYPE_VOIDP,  # FileLogHandle : void*
    Fiddle::TYPE_VOIDP,  # LogSectionName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # SourceFilename : LPCWSTR
    Fiddle::TYPE_VOIDP,  # TargetFilename : LPCWSTR
    -Fiddle::TYPE_INT,  # Checksum : DWORD
    Fiddle::TYPE_VOIDP,  # DiskTagfile : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # DiskDescription : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # OtherInfo : LPCWSTR optional
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupLogFileW(
        FileLogHandle: *mut (),  // void*
        LogSectionName: *const u16,  // LPCWSTR optional
        SourceFilename: *const u16,  // LPCWSTR
        TargetFilename: *const u16,  // LPCWSTR
        Checksum: u32,  // DWORD
        DiskTagfile: *const u16,  // LPCWSTR optional
        DiskDescription: *const u16,  // LPCWSTR optional
        OtherInfo: *const u16,  // LPCWSTR optional
        Flags: u32  // DWORD
    ) -> 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 SetupLogFileW(IntPtr FileLogHandle, [MarshalAs(UnmanagedType.LPWStr)] string LogSectionName, [MarshalAs(UnmanagedType.LPWStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPWStr)] string TargetFilename, uint Checksum, [MarshalAs(UnmanagedType.LPWStr)] string DiskTagfile, [MarshalAs(UnmanagedType.LPWStr)] string DiskDescription, [MarshalAs(UnmanagedType.LPWStr)] string OtherInfo, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupLogFileW' -Namespace Win32 -PassThru
# $api::SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
#uselib "SETUPAPI.dll"
#func global SetupLogFileW "SetupLogFileW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupLogFileW FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags   ; 戻り値は stat
; FileLogHandle : void* -> "wptr"
; LogSectionName : LPCWSTR optional -> "wptr"
; SourceFilename : LPCWSTR -> "wptr"
; TargetFilename : LPCWSTR -> "wptr"
; Checksum : DWORD -> "wptr"
; DiskTagfile : LPCWSTR optional -> "wptr"
; DiskDescription : LPCWSTR optional -> "wptr"
; OtherInfo : LPCWSTR optional -> "wptr"
; Flags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupLogFileW "SetupLogFileW" sptr, wstr, wstr, wstr, int, wstr, wstr, wstr, int
; res = SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
; FileLogHandle : void* -> "sptr"
; LogSectionName : LPCWSTR optional -> "wstr"
; SourceFilename : LPCWSTR -> "wstr"
; TargetFilename : LPCWSTR -> "wstr"
; Checksum : DWORD -> "int"
; DiskTagfile : LPCWSTR optional -> "wstr"
; DiskDescription : LPCWSTR optional -> "wstr"
; OtherInfo : LPCWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; BOOL SetupLogFileW(void* FileLogHandle, LPCWSTR LogSectionName, LPCWSTR SourceFilename, LPCWSTR TargetFilename, DWORD Checksum, LPCWSTR DiskTagfile, LPCWSTR DiskDescription, LPCWSTR OtherInfo, DWORD Flags)
#uselib "SETUPAPI.dll"
#cfunc global SetupLogFileW "SetupLogFileW" intptr, wstr, wstr, wstr, int, wstr, wstr, wstr, int
; res = SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
; FileLogHandle : void* -> "intptr"
; LogSectionName : LPCWSTR optional -> "wstr"
; SourceFilename : LPCWSTR -> "wstr"
; TargetFilename : LPCWSTR -> "wstr"
; Checksum : DWORD -> "int"
; DiskTagfile : LPCWSTR optional -> "wstr"
; DiskDescription : LPCWSTR optional -> "wstr"
; OtherInfo : LPCWSTR optional -> "wstr"
; Flags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupLogFileW = setupapi.NewProc("SetupLogFileW")
)

// FileLogHandle (void*), LogSectionName (LPCWSTR optional), SourceFilename (LPCWSTR), TargetFilename (LPCWSTR), Checksum (DWORD), DiskTagfile (LPCWSTR optional), DiskDescription (LPCWSTR optional), OtherInfo (LPCWSTR optional), Flags (DWORD)
r1, _, err := procSetupLogFileW.Call(
	uintptr(FileLogHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(LogSectionName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceFilename))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetFilename))),
	uintptr(Checksum),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DiskTagfile))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DiskDescription))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(OtherInfo))),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupLogFileW(
  FileLogHandle: Pointer;   // void*
  LogSectionName: PWideChar;   // LPCWSTR optional
  SourceFilename: PWideChar;   // LPCWSTR
  TargetFilename: PWideChar;   // LPCWSTR
  Checksum: DWORD;   // DWORD
  DiskTagfile: PWideChar;   // LPCWSTR optional
  DiskDescription: PWideChar;   // LPCWSTR optional
  OtherInfo: PWideChar;   // LPCWSTR optional
  Flags: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupLogFileW';
result := DllCall("SETUPAPI\SetupLogFileW"
    , "Ptr", FileLogHandle   ; void*
    , "WStr", LogSectionName   ; LPCWSTR optional
    , "WStr", SourceFilename   ; LPCWSTR
    , "WStr", TargetFilename   ; LPCWSTR
    , "UInt", Checksum   ; DWORD
    , "WStr", DiskTagfile   ; LPCWSTR optional
    , "WStr", DiskDescription   ; LPCWSTR optional
    , "WStr", OtherInfo   ; LPCWSTR optional
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: BOOL
●SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags) = DLL("SETUPAPI.dll", "bool SetupLogFileW(void*, char*, char*, char*, dword, char*, char*, char*, dword)")
# 呼び出し: SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
# FileLogHandle : void* -> "void*"
# LogSectionName : LPCWSTR optional -> "char*"
# SourceFilename : LPCWSTR -> "char*"
# TargetFilename : LPCWSTR -> "char*"
# Checksum : DWORD -> "dword"
# DiskTagfile : LPCWSTR optional -> "char*"
# DiskDescription : LPCWSTR optional -> "char*"
# OtherInfo : LPCWSTR optional -> "char*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。