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

SetupCommitFileQueueW

関数
キューに登録された全ファイル操作を実行する(Unicode)。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupCommitFileQueueW(
    HWND Owner,   // optional
    void* QueueHandle,
    PSP_FILE_CALLBACK_W MsgHandler,
    void* Context
);

パラメーター

名前方向説明
OwnerHWNDinoptional進捗ダイアログの親となるウィンドウハンドル。NULL可。
QueueHandlevoid*in登録済み操作を実行するファイルキューのハンドル。
MsgHandlerPSP_FILE_CALLBACK_Winコピー進捗通知を受け取るコールバック関数(Unicode)。
Contextvoid*inコールバックへ渡すユーザー定義のコンテキストポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupCommitFileQueueW(
    HWND Owner,   // optional
    void* QueueHandle,
    PSP_FILE_CALLBACK_W MsgHandler,
    void* Context
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupCommitFileQueueW(
    IntPtr Owner,   // HWND optional
    IntPtr QueueHandle,   // void*
    IntPtr MsgHandler,   // PSP_FILE_CALLBACK_W
    IntPtr Context   // void*
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupCommitFileQueueW(
    Owner As IntPtr,   ' HWND optional
    QueueHandle As IntPtr,   ' void*
    MsgHandler As IntPtr,   ' PSP_FILE_CALLBACK_W
    Context As IntPtr   ' void*
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' Owner : HWND optional
' QueueHandle : void*
' MsgHandler : PSP_FILE_CALLBACK_W
' Context : void*
Declare PtrSafe Function SetupCommitFileQueueW Lib "setupapi" ( _
    ByVal Owner As LongPtr, _
    ByVal QueueHandle As LongPtr, _
    ByVal MsgHandler As LongPtr, _
    ByVal Context 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

SetupCommitFileQueueW = ctypes.windll.setupapi.SetupCommitFileQueueW
SetupCommitFileQueueW.restype = wintypes.BOOL
SetupCommitFileQueueW.argtypes = [
    wintypes.HANDLE,  # Owner : HWND optional
    ctypes.POINTER(None),  # QueueHandle : void*
    ctypes.c_void_p,  # MsgHandler : PSP_FILE_CALLBACK_W
    ctypes.POINTER(None),  # Context : void*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupCommitFileQueueW = Fiddle::Function.new(
  lib['SetupCommitFileQueueW'],
  [
    Fiddle::TYPE_VOIDP,  # Owner : HWND optional
    Fiddle::TYPE_VOIDP,  # QueueHandle : void*
    Fiddle::TYPE_VOIDP,  # MsgHandler : PSP_FILE_CALLBACK_W
    Fiddle::TYPE_VOIDP,  # Context : void*
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupCommitFileQueueW(
        Owner: *mut core::ffi::c_void,  // HWND optional
        QueueHandle: *mut (),  // void*
        MsgHandler: *const core::ffi::c_void,  // PSP_FILE_CALLBACK_W
        Context: *mut ()  // void*
    ) -> 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 SetupCommitFileQueueW(IntPtr Owner, IntPtr QueueHandle, IntPtr MsgHandler, IntPtr Context);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupCommitFileQueueW' -Namespace Win32 -PassThru
# $api::SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
#uselib "SETUPAPI.dll"
#func global SetupCommitFileQueueW "SetupCommitFileQueueW" wptr, wptr, wptr, wptr
; SetupCommitFileQueueW Owner, QueueHandle, MsgHandler, Context   ; 戻り値は stat
; Owner : HWND optional -> "wptr"
; QueueHandle : void* -> "wptr"
; MsgHandler : PSP_FILE_CALLBACK_W -> "wptr"
; Context : void* -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupCommitFileQueueW "SetupCommitFileQueueW" sptr, sptr, sptr, sptr
; res = SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
; Owner : HWND optional -> "sptr"
; QueueHandle : void* -> "sptr"
; MsgHandler : PSP_FILE_CALLBACK_W -> "sptr"
; Context : void* -> "sptr"
; BOOL SetupCommitFileQueueW(HWND Owner, void* QueueHandle, PSP_FILE_CALLBACK_W MsgHandler, void* Context)
#uselib "SETUPAPI.dll"
#cfunc global SetupCommitFileQueueW "SetupCommitFileQueueW" intptr, intptr, intptr, intptr
; res = SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
; Owner : HWND optional -> "intptr"
; QueueHandle : void* -> "intptr"
; MsgHandler : PSP_FILE_CALLBACK_W -> "intptr"
; Context : void* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupCommitFileQueueW = setupapi.NewProc("SetupCommitFileQueueW")
)

// Owner (HWND optional), QueueHandle (void*), MsgHandler (PSP_FILE_CALLBACK_W), Context (void*)
r1, _, err := procSetupCommitFileQueueW.Call(
	uintptr(Owner),
	uintptr(QueueHandle),
	uintptr(MsgHandler),
	uintptr(Context),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupCommitFileQueueW(
  Owner: THandle;   // HWND optional
  QueueHandle: Pointer;   // void*
  MsgHandler: Pointer;   // PSP_FILE_CALLBACK_W
  Context: Pointer   // void*
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupCommitFileQueueW';
result := DllCall("SETUPAPI\SetupCommitFileQueueW"
    , "Ptr", Owner   ; HWND optional
    , "Ptr", QueueHandle   ; void*
    , "Ptr", MsgHandler   ; PSP_FILE_CALLBACK_W
    , "Ptr", Context   ; void*
    , "Int")   ; return: BOOL
●SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context) = DLL("SETUPAPI.dll", "bool SetupCommitFileQueueW(void*, void*, void*, void*)")
# 呼び出し: SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
# Owner : HWND optional -> "void*"
# QueueHandle : void* -> "void*"
# MsgHandler : PSP_FILE_CALLBACK_W -> "void*"
# Context : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "setupapi" fn SetupCommitFileQueueW(
    Owner: ?*anyopaque, // HWND optional
    QueueHandle: ?*anyopaque, // void*
    MsgHandler: ?*anyopaque, // PSP_FILE_CALLBACK_W
    Context: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc SetupCommitFileQueueW(
    Owner: pointer,  # HWND optional
    QueueHandle: pointer,  # void*
    MsgHandler: pointer,  # PSP_FILE_CALLBACK_W
    Context: pointer  # void*
): int32 {.importc: "SetupCommitFileQueueW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "setupapi");
extern(Windows)
int SetupCommitFileQueueW(
    void* Owner,   // HWND optional
    void* QueueHandle,   // void*
    void* MsgHandler,   // PSP_FILE_CALLBACK_W
    void* Context   // void*
);
ccall((:SetupCommitFileQueueW, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
      Owner, QueueHandle, MsgHandler, Context)
# Owner : HWND optional -> Ptr{Cvoid}
# QueueHandle : void* -> Ptr{Cvoid}
# MsgHandler : PSP_FILE_CALLBACK_W -> Ptr{Cvoid}
# Context : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupCommitFileQueueW(
    void* Owner,
    void* QueueHandle,
    void* MsgHandler,
    void* Context);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
-- Owner : HWND optional
-- QueueHandle : void*
-- MsgHandler : PSP_FILE_CALLBACK_W
-- Context : void*
-- 構造体/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 SetupCommitFileQueueW = lib.func('__stdcall', 'SetupCommitFileQueueW', 'int32_t', ['void *', 'void *', 'void *', 'void *']);
// SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
// Owner : HWND optional -> 'void *'
// QueueHandle : void* -> 'void *'
// MsgHandler : PSP_FILE_CALLBACK_W -> 'void *'
// Context : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupCommitFileQueueW: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context)
// Owner : HWND optional -> "pointer"
// QueueHandle : void* -> "pointer"
// MsgHandler : PSP_FILE_CALLBACK_W -> "pointer"
// Context : void* -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupCommitFileQueueW(
    void* Owner,
    void* QueueHandle,
    void* MsgHandler,
    void* Context);
C, "SETUPAPI.dll");
// $ffi->SetupCommitFileQueueW(Owner, QueueHandle, MsgHandler, Context);
// Owner : HWND optional
// QueueHandle : void*
// MsgHandler : PSP_FILE_CALLBACK_W
// Context : void*
// 構造体/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 SetupCommitFileQueueW(
        Pointer Owner,   // HWND optional
        Pointer QueueHandle,   // void*
        Callback MsgHandler,   // PSP_FILE_CALLBACK_W
        Pointer Context   // void*
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupCommitFileQueueW = SetupCommitFileQueueW(
    Owner : Void*,   # HWND optional
    QueueHandle : Void*,   # void*
    MsgHandler : Void*,   # PSP_FILE_CALLBACK_W
    Context : Void*   # void*
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetupCommitFileQueueWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef SetupCommitFileQueueWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final SetupCommitFileQueueW = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupCommitFileQueueWNative, SetupCommitFileQueueWDart>('SetupCommitFileQueueW');
// Owner : HWND optional -> Pointer<Void>
// QueueHandle : void* -> Pointer<Void>
// MsgHandler : PSP_FILE_CALLBACK_W -> Pointer<Void>
// Context : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupCommitFileQueueW(
  Owner: THandle;   // HWND optional
  QueueHandle: Pointer;   // void*
  MsgHandler: Pointer;   // PSP_FILE_CALLBACK_W
  Context: Pointer   // void*
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupCommitFileQueueW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupCommitFileQueueW"
  c_SetupCommitFileQueueW :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO CInt
-- Owner : HWND optional -> Ptr ()
-- QueueHandle : void* -> Ptr ()
-- MsgHandler : PSP_FILE_CALLBACK_W -> Ptr ()
-- Context : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupcommitfilequeuew =
  foreign "SetupCommitFileQueueW"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* Owner : HWND optional -> (ptr void) *)
(* QueueHandle : void* -> (ptr void) *)
(* MsgHandler : PSP_FILE_CALLBACK_W -> (ptr void) *)
(* Context : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)

(cffi:defcfun ("SetupCommitFileQueueW" setup-commit-file-queue-w :convention :stdcall) :int32
  (owner :pointer)   ; HWND optional
  (queue-handle :pointer)   ; void*
  (msg-handler :pointer)   ; PSP_FILE_CALLBACK_W
  (context :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupCommitFileQueueW = Win32::API::More->new('SETUPAPI',
    'BOOL SetupCommitFileQueueW(HANDLE Owner, LPVOID QueueHandle, LPVOID MsgHandler, LPVOID Context)');
# my $ret = $SetupCommitFileQueueW->Call($Owner, $QueueHandle, $MsgHandler, $Context);
# Owner : HWND optional -> HANDLE
# QueueHandle : void* -> LPVOID
# MsgHandler : PSP_FILE_CALLBACK_W -> LPVOID
# Context : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
使用する型