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

SetupQueueCopyA

関数
ファイルキューにコピー操作を追加する(ANSI)。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupQueueCopyA(
    void* QueueHandle,
    LPCSTR SourceRootPath,   // optional
    LPCSTR SourcePath,   // optional
    LPCSTR SourceFilename,
    LPCSTR SourceDescription,   // optional
    LPCSTR SourceTagfile,   // optional
    LPCSTR TargetDirectory,
    LPCSTR TargetFilename,   // optional
    DWORD CopyStyle
);

パラメーター

名前方向説明
QueueHandlevoid*inコピー操作を登録する対象のセットアップファイルキューハンドル。
SourceRootPathLPCSTRinoptionalソースのルートパス(ANSI)。
SourcePathLPCSTRinoptionalルートからの相対サブパス(ANSI)。NULL可。
SourceFilenameLPCSTRinコピー元ファイル名(ANSI)。
SourceDescriptionLPCSTRinoptionalソースメディアの説明文字列(ANSI)。NULL可。
SourceTagfileLPCSTRinoptionalメディア識別用タグファイル名(ANSI)。NULL可。
TargetDirectoryLPCSTRinコピー先ディレクトリ(ANSI)。
TargetFilenameLPCSTRinoptionalコピー先ファイル名(ANSI)。NULLで元名を使う。
CopyStyleDWORDinコピー動作を制御するスタイルフラグ。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupQueueCopyA = ctypes.windll.setupapi.SetupQueueCopyA
SetupQueueCopyA.restype = wintypes.BOOL
SetupQueueCopyA.argtypes = [
    ctypes.POINTER(None),  # QueueHandle : void*
    wintypes.LPCSTR,  # SourceRootPath : LPCSTR optional
    wintypes.LPCSTR,  # SourcePath : LPCSTR optional
    wintypes.LPCSTR,  # SourceFilename : LPCSTR
    wintypes.LPCSTR,  # SourceDescription : LPCSTR optional
    wintypes.LPCSTR,  # SourceTagfile : LPCSTR optional
    wintypes.LPCSTR,  # TargetDirectory : LPCSTR
    wintypes.LPCSTR,  # TargetFilename : LPCSTR optional
    wintypes.DWORD,  # CopyStyle : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupQueueCopyA = Fiddle::Function.new(
  lib['SetupQueueCopyA'],
  [
    Fiddle::TYPE_VOIDP,  # QueueHandle : void*
    Fiddle::TYPE_VOIDP,  # SourceRootPath : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # SourcePath : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # SourceFilename : LPCSTR
    Fiddle::TYPE_VOIDP,  # SourceDescription : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # SourceTagfile : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # TargetDirectory : LPCSTR
    Fiddle::TYPE_VOIDP,  # TargetFilename : LPCSTR optional
    -Fiddle::TYPE_INT,  # CopyStyle : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupQueueCopyA(
        QueueHandle: *mut (),  // void*
        SourceRootPath: *const u8,  // LPCSTR optional
        SourcePath: *const u8,  // LPCSTR optional
        SourceFilename: *const u8,  // LPCSTR
        SourceDescription: *const u8,  // LPCSTR optional
        SourceTagfile: *const u8,  // LPCSTR optional
        TargetDirectory: *const u8,  // LPCSTR
        TargetFilename: *const u8,  // LPCSTR optional
        CopyStyle: 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 SetupQueueCopyA(IntPtr QueueHandle, [MarshalAs(UnmanagedType.LPStr)] string SourceRootPath, [MarshalAs(UnmanagedType.LPStr)] string SourcePath, [MarshalAs(UnmanagedType.LPStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPStr)] string SourceDescription, [MarshalAs(UnmanagedType.LPStr)] string SourceTagfile, [MarshalAs(UnmanagedType.LPStr)] string TargetDirectory, [MarshalAs(UnmanagedType.LPStr)] string TargetFilename, uint CopyStyle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueCopyA' -Namespace Win32 -PassThru
# $api::SetupQueueCopyA(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
#uselib "SETUPAPI.dll"
#func global SetupQueueCopyA "SetupQueueCopyA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupQueueCopyA QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle   ; 戻り値は stat
; QueueHandle : void* -> "sptr"
; SourceRootPath : LPCSTR optional -> "sptr"
; SourcePath : LPCSTR optional -> "sptr"
; SourceFilename : LPCSTR -> "sptr"
; SourceDescription : LPCSTR optional -> "sptr"
; SourceTagfile : LPCSTR optional -> "sptr"
; TargetDirectory : LPCSTR -> "sptr"
; TargetFilename : LPCSTR optional -> "sptr"
; CopyStyle : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueCopyA "SetupQueueCopyA" sptr, str, str, str, str, str, str, str, int
; res = SetupQueueCopyA(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
; QueueHandle : void* -> "sptr"
; SourceRootPath : LPCSTR optional -> "str"
; SourcePath : LPCSTR optional -> "str"
; SourceFilename : LPCSTR -> "str"
; SourceDescription : LPCSTR optional -> "str"
; SourceTagfile : LPCSTR optional -> "str"
; TargetDirectory : LPCSTR -> "str"
; TargetFilename : LPCSTR optional -> "str"
; CopyStyle : DWORD -> "int"
; BOOL SetupQueueCopyA(void* QueueHandle, LPCSTR SourceRootPath, LPCSTR SourcePath, LPCSTR SourceFilename, LPCSTR SourceDescription, LPCSTR SourceTagfile, LPCSTR TargetDirectory, LPCSTR TargetFilename, DWORD CopyStyle)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueCopyA "SetupQueueCopyA" intptr, str, str, str, str, str, str, str, int
; res = SetupQueueCopyA(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
; QueueHandle : void* -> "intptr"
; SourceRootPath : LPCSTR optional -> "str"
; SourcePath : LPCSTR optional -> "str"
; SourceFilename : LPCSTR -> "str"
; SourceDescription : LPCSTR optional -> "str"
; SourceTagfile : LPCSTR optional -> "str"
; TargetDirectory : LPCSTR -> "str"
; TargetFilename : LPCSTR optional -> "str"
; CopyStyle : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupQueueCopyA = setupapi.NewProc("SetupQueueCopyA")
)

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

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

foreign import stdcall safe "SetupQueueCopyA"
  c_SetupQueueCopyA :: Ptr () -> CString -> CString -> CString -> CString -> CString -> CString -> CString -> Word32 -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- SourceRootPath : LPCSTR optional -> CString
-- SourcePath : LPCSTR optional -> CString
-- SourceFilename : LPCSTR -> CString
-- SourceDescription : LPCSTR optional -> CString
-- SourceTagfile : LPCSTR optional -> CString
-- TargetDirectory : LPCSTR -> CString
-- TargetFilename : LPCSTR optional -> CString
-- CopyStyle : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupqueuecopya =
  foreign "SetupQueueCopyA"
    ((ptr void) @-> string @-> string @-> string @-> string @-> string @-> string @-> string @-> uint32_t @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* SourceRootPath : LPCSTR optional -> string *)
(* SourcePath : LPCSTR optional -> string *)
(* SourceFilename : LPCSTR -> string *)
(* SourceDescription : LPCSTR optional -> string *)
(* SourceTagfile : LPCSTR optional -> string *)
(* TargetDirectory : LPCSTR -> string *)
(* TargetFilename : LPCSTR optional -> string *)
(* CopyStyle : 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 ("SetupQueueCopyA" setup-queue-copy-a :convention :stdcall) :int32
  (queue-handle :pointer)   ; void*
  (source-root-path :string)   ; LPCSTR optional
  (source-path :string)   ; LPCSTR optional
  (source-filename :string)   ; LPCSTR
  (source-description :string)   ; LPCSTR optional
  (source-tagfile :string)   ; LPCSTR optional
  (target-directory :string)   ; LPCSTR
  (target-filename :string)   ; LPCSTR optional
  (copy-style :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupQueueCopyA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupQueueCopyA(LPVOID QueueHandle, LPCSTR SourceRootPath, LPCSTR SourcePath, LPCSTR SourceFilename, LPCSTR SourceDescription, LPCSTR SourceTagfile, LPCSTR TargetDirectory, LPCSTR TargetFilename, DWORD CopyStyle)');
# my $ret = $SetupQueueCopyA->Call($QueueHandle, $SourceRootPath, $SourcePath, $SourceFilename, $SourceDescription, $SourceTagfile, $TargetDirectory, $TargetFilename, $CopyStyle);
# QueueHandle : void* -> LPVOID
# SourceRootPath : LPCSTR optional -> LPCSTR
# SourcePath : LPCSTR optional -> LPCSTR
# SourceFilename : LPCSTR -> LPCSTR
# SourceDescription : LPCSTR optional -> LPCSTR
# SourceTagfile : LPCSTR optional -> LPCSTR
# TargetDirectory : LPCSTR -> LPCSTR
# TargetFilename : LPCSTR optional -> LPCSTR
# CopyStyle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い