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

SetupLogFileA

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

シグネチャ

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

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

パラメーター

名前方向説明
FileLogHandlevoid*in記録先のファイルログのハンドル。
LogSectionNameLPCSTRinoptionalログエントリを登録するセクション名(ANSI)。NULL可。
SourceFilenameLPCSTRin記録対象のソースファイル名(ANSI)。NULL可。
TargetFilenameLPCSTRin記録対象のターゲットファイル名(ANSI)。
ChecksumDWORDinファイルのチェックサム値。
DiskTagfileLPCSTRinoptionalソースディスクのタグファイル名(ANSI)。NULL可。
DiskDescriptionLPCSTRinoptionalソースディスクの説明文字列(ANSI)。NULL可。
OtherInfoLPCSTRinoptional付加的な情報文字列(ANSI)。NULL可。
FlagsDWORDinSPFILELOG_*系のログ記録動作フラグ。

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL SetupLogFileA(
    void* FileLogHandle,
    LPCSTR LogSectionName,   // optional
    LPCSTR SourceFilename,
    LPCSTR TargetFilename,
    DWORD Checksum,
    LPCSTR DiskTagfile,   // optional
    LPCSTR DiskDescription,   // optional
    LPCSTR OtherInfo,   // optional
    DWORD Flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupLogFileA(
    IntPtr FileLogHandle,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string LogSectionName,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string SourceFilename,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string TargetFilename,   // LPCSTR
    uint Checksum,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string DiskTagfile,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string DiskDescription,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string OtherInfo,   // LPCSTR optional
    uint Flags   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupLogFileA(
    FileLogHandle As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> LogSectionName As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> SourceFilename As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> TargetFilename As String,   ' LPCSTR
    Checksum As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> DiskTagfile As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> DiskDescription As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> OtherInfo As String,   ' LPCSTR optional
    Flags As UInteger   ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' FileLogHandle : void*
' LogSectionName : LPCSTR optional
' SourceFilename : LPCSTR
' TargetFilename : LPCSTR
' Checksum : DWORD
' DiskTagfile : LPCSTR optional
' DiskDescription : LPCSTR optional
' OtherInfo : LPCSTR optional
' Flags : DWORD
Declare PtrSafe Function SetupLogFileA Lib "setupapi" ( _
    ByVal FileLogHandle As LongPtr, _
    ByVal LogSectionName As String, _
    ByVal SourceFilename As String, _
    ByVal TargetFilename As String, _
    ByVal Checksum As Long, _
    ByVal DiskTagfile As String, _
    ByVal DiskDescription As String, _
    ByVal OtherInfo As String, _
    ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupLogFileA = ctypes.windll.setupapi.SetupLogFileA
SetupLogFileA.restype = wintypes.BOOL
SetupLogFileA.argtypes = [
    ctypes.POINTER(None),  # FileLogHandle : void*
    wintypes.LPCSTR,  # LogSectionName : LPCSTR optional
    wintypes.LPCSTR,  # SourceFilename : LPCSTR
    wintypes.LPCSTR,  # TargetFilename : LPCSTR
    wintypes.DWORD,  # Checksum : DWORD
    wintypes.LPCSTR,  # DiskTagfile : LPCSTR optional
    wintypes.LPCSTR,  # DiskDescription : LPCSTR optional
    wintypes.LPCSTR,  # OtherInfo : LPCSTR 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')
SetupLogFileA = Fiddle::Function.new(
  lib['SetupLogFileA'],
  [
    Fiddle::TYPE_VOIDP,  # FileLogHandle : void*
    Fiddle::TYPE_VOIDP,  # LogSectionName : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # SourceFilename : LPCSTR
    Fiddle::TYPE_VOIDP,  # TargetFilename : LPCSTR
    -Fiddle::TYPE_INT,  # Checksum : DWORD
    Fiddle::TYPE_VOIDP,  # DiskTagfile : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # DiskDescription : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # OtherInfo : LPCSTR optional
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupLogFileA(
        FileLogHandle: *mut (),  // void*
        LogSectionName: *const u8,  // LPCSTR optional
        SourceFilename: *const u8,  // LPCSTR
        TargetFilename: *const u8,  // LPCSTR
        Checksum: u32,  // DWORD
        DiskTagfile: *const u8,  // LPCSTR optional
        DiskDescription: *const u8,  // LPCSTR optional
        OtherInfo: *const u8,  // LPCSTR 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.Ansi, SetLastError = true)]
public static extern bool SetupLogFileA(IntPtr FileLogHandle, [MarshalAs(UnmanagedType.LPStr)] string LogSectionName, [MarshalAs(UnmanagedType.LPStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPStr)] string TargetFilename, uint Checksum, [MarshalAs(UnmanagedType.LPStr)] string DiskTagfile, [MarshalAs(UnmanagedType.LPStr)] string DiskDescription, [MarshalAs(UnmanagedType.LPStr)] string OtherInfo, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupLogFileA' -Namespace Win32 -PassThru
# $api::SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
#uselib "SETUPAPI.dll"
#func global SetupLogFileA "SetupLogFileA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupLogFileA FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags   ; 戻り値は stat
; FileLogHandle : void* -> "sptr"
; LogSectionName : LPCSTR optional -> "sptr"
; SourceFilename : LPCSTR -> "sptr"
; TargetFilename : LPCSTR -> "sptr"
; Checksum : DWORD -> "sptr"
; DiskTagfile : LPCSTR optional -> "sptr"
; DiskDescription : LPCSTR optional -> "sptr"
; OtherInfo : LPCSTR optional -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupLogFileA "SetupLogFileA" sptr, str, str, str, int, str, str, str, int
; res = SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
; FileLogHandle : void* -> "sptr"
; LogSectionName : LPCSTR optional -> "str"
; SourceFilename : LPCSTR -> "str"
; TargetFilename : LPCSTR -> "str"
; Checksum : DWORD -> "int"
; DiskTagfile : LPCSTR optional -> "str"
; DiskDescription : LPCSTR optional -> "str"
; OtherInfo : LPCSTR optional -> "str"
; Flags : DWORD -> "int"
; BOOL SetupLogFileA(void* FileLogHandle, LPCSTR LogSectionName, LPCSTR SourceFilename, LPCSTR TargetFilename, DWORD Checksum, LPCSTR DiskTagfile, LPCSTR DiskDescription, LPCSTR OtherInfo, DWORD Flags)
#uselib "SETUPAPI.dll"
#cfunc global SetupLogFileA "SetupLogFileA" intptr, str, str, str, int, str, str, str, int
; res = SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
; FileLogHandle : void* -> "intptr"
; LogSectionName : LPCSTR optional -> "str"
; SourceFilename : LPCSTR -> "str"
; TargetFilename : LPCSTR -> "str"
; Checksum : DWORD -> "int"
; DiskTagfile : LPCSTR optional -> "str"
; DiskDescription : LPCSTR optional -> "str"
; OtherInfo : LPCSTR optional -> "str"
; Flags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupLogFileA = setupapi.NewProc("SetupLogFileA")
)

// FileLogHandle (void*), LogSectionName (LPCSTR optional), SourceFilename (LPCSTR), TargetFilename (LPCSTR), Checksum (DWORD), DiskTagfile (LPCSTR optional), DiskDescription (LPCSTR optional), OtherInfo (LPCSTR optional), Flags (DWORD)
r1, _, err := procSetupLogFileA.Call(
	uintptr(FileLogHandle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(LogSectionName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceFilename))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetFilename))),
	uintptr(Checksum),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DiskTagfile))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DiskDescription))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(OtherInfo))),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupLogFileA(
  FileLogHandle: Pointer;   // void*
  LogSectionName: PAnsiChar;   // LPCSTR optional
  SourceFilename: PAnsiChar;   // LPCSTR
  TargetFilename: PAnsiChar;   // LPCSTR
  Checksum: DWORD;   // DWORD
  DiskTagfile: PAnsiChar;   // LPCSTR optional
  DiskDescription: PAnsiChar;   // LPCSTR optional
  OtherInfo: PAnsiChar;   // LPCSTR optional
  Flags: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupLogFileA';
result := DllCall("SETUPAPI\SetupLogFileA"
    , "Ptr", FileLogHandle   ; void*
    , "AStr", LogSectionName   ; LPCSTR optional
    , "AStr", SourceFilename   ; LPCSTR
    , "AStr", TargetFilename   ; LPCSTR
    , "UInt", Checksum   ; DWORD
    , "AStr", DiskTagfile   ; LPCSTR optional
    , "AStr", DiskDescription   ; LPCSTR optional
    , "AStr", OtherInfo   ; LPCSTR optional
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: BOOL
●SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags) = DLL("SETUPAPI.dll", "bool SetupLogFileA(void*, char*, char*, char*, dword, char*, char*, char*, dword)")
# 呼び出し: SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
# FileLogHandle : void* -> "void*"
# LogSectionName : LPCSTR optional -> "char*"
# SourceFilename : LPCSTR -> "char*"
# TargetFilename : LPCSTR -> "char*"
# Checksum : DWORD -> "dword"
# DiskTagfile : LPCSTR optional -> "char*"
# DiskDescription : LPCSTR optional -> "char*"
# OtherInfo : LPCSTR optional -> "char*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "setupapi" fn SetupLogFileA(
    FileLogHandle: ?*anyopaque, // void*
    LogSectionName: [*c]const u8, // LPCSTR optional
    SourceFilename: [*c]const u8, // LPCSTR
    TargetFilename: [*c]const u8, // LPCSTR
    Checksum: u32, // DWORD
    DiskTagfile: [*c]const u8, // LPCSTR optional
    DiskDescription: [*c]const u8, // LPCSTR optional
    OtherInfo: [*c]const u8, // LPCSTR optional
    Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc SetupLogFileA(
    FileLogHandle: pointer,  # void*
    LogSectionName: cstring,  # LPCSTR optional
    SourceFilename: cstring,  # LPCSTR
    TargetFilename: cstring,  # LPCSTR
    Checksum: uint32,  # DWORD
    DiskTagfile: cstring,  # LPCSTR optional
    DiskDescription: cstring,  # LPCSTR optional
    OtherInfo: cstring,  # LPCSTR optional
    Flags: uint32  # DWORD
): int32 {.importc: "SetupLogFileA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupLogFileA(
    void* FileLogHandle,   // void*
    const(char)* LogSectionName,   // LPCSTR optional
    const(char)* SourceFilename,   // LPCSTR
    const(char)* TargetFilename,   // LPCSTR
    uint Checksum,   // DWORD
    const(char)* DiskTagfile,   // LPCSTR optional
    const(char)* DiskDescription,   // LPCSTR optional
    const(char)* OtherInfo,   // LPCSTR optional
    uint Flags   // DWORD
);
ccall((:SetupLogFileA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cstring, Cstring, Cstring, UInt32, Cstring, Cstring, Cstring, UInt32),
      FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
# FileLogHandle : void* -> Ptr{Cvoid}
# LogSectionName : LPCSTR optional -> Cstring
# SourceFilename : LPCSTR -> Cstring
# TargetFilename : LPCSTR -> Cstring
# Checksum : DWORD -> UInt32
# DiskTagfile : LPCSTR optional -> Cstring
# DiskDescription : LPCSTR optional -> Cstring
# OtherInfo : LPCSTR optional -> Cstring
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupLogFileA(
    void* FileLogHandle,
    const char* LogSectionName,
    const char* SourceFilename,
    const char* TargetFilename,
    uint32_t Checksum,
    const char* DiskTagfile,
    const char* DiskDescription,
    const char* OtherInfo,
    uint32_t Flags);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
-- FileLogHandle : void*
-- LogSectionName : LPCSTR optional
-- SourceFilename : LPCSTR
-- TargetFilename : LPCSTR
-- Checksum : DWORD
-- DiskTagfile : LPCSTR optional
-- DiskDescription : LPCSTR optional
-- OtherInfo : LPCSTR optional
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupLogFileA = lib.func('__stdcall', 'SetupLogFileA', 'int32_t', ['void *', 'str', 'str', 'str', 'uint32_t', 'str', 'str', 'str', 'uint32_t']);
// SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
// FileLogHandle : void* -> 'void *'
// LogSectionName : LPCSTR optional -> 'str'
// SourceFilename : LPCSTR -> 'str'
// TargetFilename : LPCSTR -> 'str'
// Checksum : DWORD -> 'uint32_t'
// DiskTagfile : LPCSTR optional -> 'str'
// DiskDescription : LPCSTR optional -> 'str'
// OtherInfo : LPCSTR optional -> 'str'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupLogFileA: { parameters: ["pointer", "buffer", "buffer", "buffer", "u32", "buffer", "buffer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags)
// FileLogHandle : void* -> "pointer"
// LogSectionName : LPCSTR optional -> "buffer"
// SourceFilename : LPCSTR -> "buffer"
// TargetFilename : LPCSTR -> "buffer"
// Checksum : DWORD -> "u32"
// DiskTagfile : LPCSTR optional -> "buffer"
// DiskDescription : LPCSTR optional -> "buffer"
// OtherInfo : LPCSTR optional -> "buffer"
// Flags : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupLogFileA(
    void* FileLogHandle,
    const char* LogSectionName,
    const char* SourceFilename,
    const char* TargetFilename,
    uint32_t Checksum,
    const char* DiskTagfile,
    const char* DiskDescription,
    const char* OtherInfo,
    uint32_t Flags);
C, "SETUPAPI.dll");
// $ffi->SetupLogFileA(FileLogHandle, LogSectionName, SourceFilename, TargetFilename, Checksum, DiskTagfile, DiskDescription, OtherInfo, Flags);
// FileLogHandle : void*
// LogSectionName : LPCSTR optional
// SourceFilename : LPCSTR
// TargetFilename : LPCSTR
// Checksum : DWORD
// DiskTagfile : LPCSTR optional
// DiskDescription : LPCSTR optional
// OtherInfo : LPCSTR 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.ASCII_OPTIONS);
    boolean SetupLogFileA(
        Pointer FileLogHandle,   // void*
        String LogSectionName,   // LPCSTR optional
        String SourceFilename,   // LPCSTR
        String TargetFilename,   // LPCSTR
        int Checksum,   // DWORD
        String DiskTagfile,   // LPCSTR optional
        String DiskDescription,   // LPCSTR optional
        String OtherInfo,   // LPCSTR optional
        int Flags   // DWORD
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupLogFileA = SetupLogFileA(
    FileLogHandle : Void*,   # void*
    LogSectionName : UInt8*,   # LPCSTR optional
    SourceFilename : UInt8*,   # LPCSTR
    TargetFilename : UInt8*,   # LPCSTR
    Checksum : UInt32,   # DWORD
    DiskTagfile : UInt8*,   # LPCSTR optional
    DiskDescription : UInt8*,   # LPCSTR optional
    OtherInfo : UInt8*,   # LPCSTR 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 SetupLogFileANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Uint32);
typedef SetupLogFileADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int);
final SetupLogFileA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupLogFileANative, SetupLogFileADart>('SetupLogFileA');
// FileLogHandle : void* -> Pointer<Void>
// LogSectionName : LPCSTR optional -> Pointer<Utf8>
// SourceFilename : LPCSTR -> Pointer<Utf8>
// TargetFilename : LPCSTR -> Pointer<Utf8>
// Checksum : DWORD -> Uint32
// DiskTagfile : LPCSTR optional -> Pointer<Utf8>
// DiskDescription : LPCSTR optional -> Pointer<Utf8>
// OtherInfo : LPCSTR optional -> Pointer<Utf8>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupLogFileA(
  FileLogHandle: Pointer;   // void*
  LogSectionName: PAnsiChar;   // LPCSTR optional
  SourceFilename: PAnsiChar;   // LPCSTR
  TargetFilename: PAnsiChar;   // LPCSTR
  Checksum: DWORD;   // DWORD
  DiskTagfile: PAnsiChar;   // LPCSTR optional
  DiskDescription: PAnsiChar;   // LPCSTR optional
  OtherInfo: PAnsiChar;   // LPCSTR optional
  Flags: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupLogFileA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupLogFileA"
  c_SetupLogFileA :: Ptr () -> CString -> CString -> CString -> Word32 -> CString -> CString -> CString -> Word32 -> IO CInt
-- FileLogHandle : void* -> Ptr ()
-- LogSectionName : LPCSTR optional -> CString
-- SourceFilename : LPCSTR -> CString
-- TargetFilename : LPCSTR -> CString
-- Checksum : DWORD -> Word32
-- DiskTagfile : LPCSTR optional -> CString
-- DiskDescription : LPCSTR optional -> CString
-- OtherInfo : LPCSTR optional -> CString
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setuplogfilea =
  foreign "SetupLogFileA"
    ((ptr void) @-> string @-> string @-> string @-> uint32_t @-> string @-> string @-> string @-> uint32_t @-> returning int32_t)
(* FileLogHandle : void* -> (ptr void) *)
(* LogSectionName : LPCSTR optional -> string *)
(* SourceFilename : LPCSTR -> string *)
(* TargetFilename : LPCSTR -> string *)
(* Checksum : DWORD -> uint32_t *)
(* DiskTagfile : LPCSTR optional -> string *)
(* DiskDescription : LPCSTR optional -> string *)
(* OtherInfo : LPCSTR optional -> string *)
(* 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 ("SetupLogFileA" setup-log-file-a :convention :stdcall) :int32
  (file-log-handle :pointer)   ; void*
  (log-section-name :string)   ; LPCSTR optional
  (source-filename :string)   ; LPCSTR
  (target-filename :string)   ; LPCSTR
  (checksum :uint32)   ; DWORD
  (disk-tagfile :string)   ; LPCSTR optional
  (disk-description :string)   ; LPCSTR optional
  (other-info :string)   ; LPCSTR optional
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupLogFileA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupLogFileA(LPVOID FileLogHandle, LPCSTR LogSectionName, LPCSTR SourceFilename, LPCSTR TargetFilename, DWORD Checksum, LPCSTR DiskTagfile, LPCSTR DiskDescription, LPCSTR OtherInfo, DWORD Flags)');
# my $ret = $SetupLogFileA->Call($FileLogHandle, $LogSectionName, $SourceFilename, $TargetFilename, $Checksum, $DiskTagfile, $DiskDescription, $OtherInfo, $Flags);
# FileLogHandle : void* -> LPVOID
# LogSectionName : LPCSTR optional -> LPCSTR
# SourceFilename : LPCSTR -> LPCSTR
# TargetFilename : LPCSTR -> LPCSTR
# Checksum : DWORD -> DWORD
# DiskTagfile : LPCSTR optional -> LPCSTR
# DiskDescription : LPCSTR optional -> LPCSTR
# OtherInfo : LPCSTR optional -> LPCSTR
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い