ホーム › Devices.DeviceAndDriverInstallation › SetupLogFileW
SetupLogFileW
関数コピーしたファイルの情報をセットアップファイルログに記録する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileLogHandle | void* | in | 記録先のファイルログのハンドル。 |
| LogSectionName | LPCWSTR | inoptional | ログエントリを登録するセクション名(Unicode)。NULL可。 |
| SourceFilename | LPCWSTR | in | 記録対象のソースファイル名(Unicode)。NULL可。 |
| TargetFilename | LPCWSTR | in | 記録対象のターゲットファイル名(Unicode)。 |
| Checksum | DWORD | in | ファイルのチェックサム値。 |
| DiskTagfile | LPCWSTR | inoptional | ソースディスクのタグファイル名(Unicode)。NULL可。 |
| DiskDescription | LPCWSTR | inoptional | ソースディスクの説明文字列(Unicode)。NULL可。 |
| OtherInfo | LPCWSTR | inoptional | 付加的な情報文字列(Unicode)。NULL可。 |
| Flags | DWORD | in | SPFILELOG_*系のログ記録動作フラグ。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupLogFileW(
FileLogHandle: ?*anyopaque, // void*
LogSectionName: [*c]const u16, // LPCWSTR optional
SourceFilename: [*c]const u16, // LPCWSTR
TargetFilename: [*c]const u16, // LPCWSTR
Checksum: u32, // DWORD
DiskTagfile: [*c]const u16, // LPCWSTR optional
DiskDescription: [*c]const u16, // LPCWSTR optional
OtherInfo: [*c]const u16, // LPCWSTR optional
Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupLogFileW(
FileLogHandle: pointer, # void*
LogSectionName: WideCString, # LPCWSTR optional
SourceFilename: WideCString, # LPCWSTR
TargetFilename: WideCString, # LPCWSTR
Checksum: uint32, # DWORD
DiskTagfile: WideCString, # LPCWSTR optional
DiskDescription: WideCString, # LPCWSTR optional
OtherInfo: WideCString, # LPCWSTR optional
Flags: uint32 # DWORD
): int32 {.importc: "SetupLogFileW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupLogFileW(
void* FileLogHandle, // void*
const(wchar)* LogSectionName, // LPCWSTR optional
const(wchar)* SourceFilename, // LPCWSTR
const(wchar)* TargetFilename, // LPCWSTR
uint Checksum, // DWORD
const(wchar)* DiskTagfile, // LPCWSTR optional
const(wchar)* DiskDescription, // LPCWSTR optional
const(wchar)* OtherInfo, // LPCWSTR optional
uint Flags // DWORD
);ccall((:SetupLogFileW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, UInt32, Cwstring, Cwstring, Cwstring, UInt32),
FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
# FileLogHandle : void* -> Ptr{Cvoid}
# LogSectionName : LPCWSTR optional -> Cwstring
# SourceFilename : LPCWSTR -> Cwstring
# TargetFilename : LPCWSTR -> Cwstring
# Checksum : DWORD -> UInt32
# DiskTagfile : LPCWSTR optional -> Cwstring
# DiskDescription : LPCWSTR optional -> Cwstring
# OtherInfo : LPCWSTR optional -> Cwstring
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupLogFileW(
void* FileLogHandle,
const uint16_t* LogSectionName,
const uint16_t* SourceFilename,
const uint16_t* TargetFilename,
uint32_t Checksum,
const uint16_t* DiskTagfile,
const uint16_t* DiskDescription,
const uint16_t* OtherInfo,
uint32_t Flags);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
-- FileLogHandle : void*
-- LogSectionName : LPCWSTR optional
-- SourceFilename : LPCWSTR
-- TargetFilename : LPCWSTR
-- Checksum : DWORD
-- DiskTagfile : LPCWSTR optional
-- DiskDescription : LPCWSTR optional
-- OtherInfo : LPCWSTR optional
-- Flags : DWORD
-- 構造体/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 SetupLogFileW = lib.func('__stdcall', 'SetupLogFileW', 'int32_t', ['void *', 'str16', 'str16', 'str16', 'uint32_t', 'str16', 'str16', 'str16', 'uint32_t']);
// SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
// FileLogHandle : void* -> 'void *'
// LogSectionName : LPCWSTR optional -> 'str16'
// SourceFilename : LPCWSTR -> 'str16'
// TargetFilename : LPCWSTR -> 'str16'
// Checksum : DWORD -> 'uint32_t'
// DiskTagfile : LPCWSTR optional -> 'str16'
// DiskDescription : LPCWSTR optional -> 'str16'
// OtherInfo : LPCWSTR optional -> 'str16'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupLogFileW: { parameters: ["pointer", "buffer", "buffer", "buffer", "u32", "buffer", "buffer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
// FileLogHandle : void* -> "pointer"
// LogSectionName : LPCWSTR optional -> "buffer"
// SourceFilename : LPCWSTR -> "buffer"
// TargetFilename : LPCWSTR -> "buffer"
// Checksum : DWORD -> "u32"
// DiskTagfile : LPCWSTR optional -> "buffer"
// DiskDescription : LPCWSTR optional -> "buffer"
// OtherInfo : LPCWSTR optional -> "buffer"
// Flags : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupLogFileW(
void* FileLogHandle,
const uint16_t* LogSectionName,
const uint16_t* SourceFilename,
const uint16_t* TargetFilename,
uint32_t Checksum,
const uint16_t* DiskTagfile,
const uint16_t* DiskDescription,
const uint16_t* OtherInfo,
uint32_t Flags);
C, "SETUPAPI.dll");
// $ffi->SetupLogFileW(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags);
// FileLogHandle : void*
// LogSectionName : LPCWSTR optional
// SourceFilename : LPCWSTR
// TargetFilename : LPCWSTR
// Checksum : DWORD
// DiskTagfile : LPCWSTR optional
// DiskDescription : LPCWSTR optional
// OtherInfo : LPCWSTR optional
// Flags : DWORD
// 構造体/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 SetupLogFileW(
Pointer FileLogHandle, // void*
WString LogSectionName, // LPCWSTR optional
WString SourceFilename, // LPCWSTR
WString TargetFilename, // LPCWSTR
int Checksum, // DWORD
WString DiskTagfile, // LPCWSTR optional
WString DiskDescription, // LPCWSTR optional
WString OtherInfo, // LPCWSTR optional
int Flags // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupLogFileW = SetupLogFileW(
FileLogHandle : Void*, # void*
LogSectionName : UInt16*, # LPCWSTR optional
SourceFilename : UInt16*, # LPCWSTR
TargetFilename : UInt16*, # LPCWSTR
Checksum : UInt32, # DWORD
DiskTagfile : UInt16*, # LPCWSTR optional
DiskDescription : UInt16*, # LPCWSTR optional
OtherInfo : UInt16*, # LPCWSTR optional
Flags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupLogFileWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef SetupLogFileWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final SetupLogFileW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupLogFileWNative, SetupLogFileWDart>('SetupLogFileW');
// FileLogHandle : void* -> Pointer<Void>
// LogSectionName : LPCWSTR optional -> Pointer<Utf16>
// SourceFilename : LPCWSTR -> Pointer<Utf16>
// TargetFilename : LPCWSTR -> Pointer<Utf16>
// Checksum : DWORD -> Uint32
// DiskTagfile : LPCWSTR optional -> Pointer<Utf16>
// DiskDescription : LPCWSTR optional -> Pointer<Utf16>
// OtherInfo : LPCWSTR optional -> Pointer<Utf16>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupLogFileW"
c_SetupLogFileW :: Ptr () -> CWString -> CWString -> CWString -> Word32 -> CWString -> CWString -> CWString -> Word32 -> IO CInt
-- FileLogHandle : void* -> Ptr ()
-- LogSectionName : LPCWSTR optional -> CWString
-- SourceFilename : LPCWSTR -> CWString
-- TargetFilename : LPCWSTR -> CWString
-- Checksum : DWORD -> Word32
-- DiskTagfile : LPCWSTR optional -> CWString
-- DiskDescription : LPCWSTR optional -> CWString
-- OtherInfo : LPCWSTR optional -> CWString
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setuplogfilew =
foreign "SetupLogFileW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* FileLogHandle : void* -> (ptr void) *)
(* LogSectionName : LPCWSTR optional -> (ptr uint16_t) *)
(* SourceFilename : LPCWSTR -> (ptr uint16_t) *)
(* TargetFilename : LPCWSTR -> (ptr uint16_t) *)
(* Checksum : DWORD -> uint32_t *)
(* DiskTagfile : LPCWSTR optional -> (ptr uint16_t) *)
(* DiskDescription : LPCWSTR optional -> (ptr uint16_t) *)
(* OtherInfo : LPCWSTR optional -> (ptr uint16_t) *)
(* Flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupLogFileW" setup-log-file-w :convention :stdcall) :int32
(file-log-handle :pointer) ; void*
(log-section-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(source-filename (:string :encoding :utf-16le)) ; LPCWSTR
(target-filename (:string :encoding :utf-16le)) ; LPCWSTR
(checksum :uint32) ; DWORD
(disk-tagfile (:string :encoding :utf-16le)) ; LPCWSTR optional
(disk-description (:string :encoding :utf-16le)) ; LPCWSTR optional
(other-info (:string :encoding :utf-16le)) ; LPCWSTR optional
(flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupLogFileW = Win32::API::More->new('SETUPAPI',
'BOOL SetupLogFileW(LPVOID FileLogHandle, LPCWSTR LogSectionName, LPCWSTR SourceFilename, LPCWSTR TargetFilename, DWORD Checksum, LPCWSTR DiskTagfile, LPCWSTR DiskDescription, LPCWSTR OtherInfo, DWORD Flags)');
# my $ret = $SetupLogFileW->Call($FileLogHandle, $LogSectionName, $SourceFilename, $TargetFilename, $Checksum, $DiskTagfile, $DiskDescription, $OtherInfo, $Flags);
# FileLogHandle : void* -> LPVOID
# LogSectionName : LPCWSTR optional -> LPCWSTR
# SourceFilename : LPCWSTR -> LPCWSTR
# TargetFilename : LPCWSTR -> LPCWSTR
# Checksum : DWORD -> DWORD
# DiskTagfile : LPCWSTR optional -> LPCWSTR
# DiskDescription : LPCWSTR optional -> LPCWSTR
# OtherInfo : LPCWSTR optional -> LPCWSTR
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupLogFileA (ANSI版) — コピーしたファイルの情報をセットアップファイルログに記録する。