ホーム › Devices.DeviceAndDriverInstallation › SetupQueueDeleteSectionW
SetupQueueDeleteSectionW
関数INFセクションのファイル群を削除操作としてキューに追加する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueueDeleteSectionW(
void* QueueHandle,
void* InfHandle,
void* ListInfHandle, // optional
LPCWSTR Section
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| QueueHandle | void* | in | 削除操作を登録するファイルキューのハンドル。 |
| InfHandle | void* | in | 削除対象を記述したINFファイルのハンドル。 |
| ListInfHandle | void* | inoptional | 追加情報を持つレイアウトINFのハンドル。NULL可。 |
| Section | LPCWSTR | in | 削除対象を列挙したINFのセクション名(Unicode)。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueueDeleteSectionW(
void* QueueHandle,
void* InfHandle,
void* ListInfHandle, // optional
LPCWSTR Section
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupQueueDeleteSectionW(
IntPtr QueueHandle, // void*
IntPtr InfHandle, // void*
IntPtr ListInfHandle, // void* optional
[MarshalAs(UnmanagedType.LPWStr)] string Section // LPCWSTR
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupQueueDeleteSectionW(
QueueHandle As IntPtr, ' void*
InfHandle As IntPtr, ' void*
ListInfHandle As IntPtr, ' void* optional
<MarshalAs(UnmanagedType.LPWStr)> Section As String ' LPCWSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' QueueHandle : void*
' InfHandle : void*
' ListInfHandle : void* optional
' Section : LPCWSTR
Declare PtrSafe Function SetupQueueDeleteSectionW Lib "setupapi" ( _
ByVal QueueHandle As LongPtr, _
ByVal InfHandle As LongPtr, _
ByVal ListInfHandle As LongPtr, _
ByVal Section 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
SetupQueueDeleteSectionW = ctypes.windll.setupapi.SetupQueueDeleteSectionW
SetupQueueDeleteSectionW.restype = wintypes.BOOL
SetupQueueDeleteSectionW.argtypes = [
ctypes.POINTER(None), # QueueHandle : void*
ctypes.POINTER(None), # InfHandle : void*
ctypes.POINTER(None), # ListInfHandle : void* optional
wintypes.LPCWSTR, # Section : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupQueueDeleteSectionW = Fiddle::Function.new(
lib['SetupQueueDeleteSectionW'],
[
Fiddle::TYPE_VOIDP, # QueueHandle : void*
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # ListInfHandle : void* optional
Fiddle::TYPE_VOIDP, # Section : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupQueueDeleteSectionW(
QueueHandle: *mut (), // void*
InfHandle: *mut (), // void*
ListInfHandle: *mut (), // void* optional
Section: *const u16 // LPCWSTR
) -> 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 SetupQueueDeleteSectionW(IntPtr QueueHandle, IntPtr InfHandle, IntPtr ListInfHandle, [MarshalAs(UnmanagedType.LPWStr)] string Section);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueDeleteSectionW' -Namespace Win32 -PassThru
# $api::SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)#uselib "SETUPAPI.dll"
#func global SetupQueueDeleteSectionW "SetupQueueDeleteSectionW" wptr, wptr, wptr, wptr
; SetupQueueDeleteSectionW QueueHandle, InfHandle, ListInfHandle, Section ; 戻り値は stat
; QueueHandle : void* -> "wptr"
; InfHandle : void* -> "wptr"
; ListInfHandle : void* optional -> "wptr"
; Section : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupQueueDeleteSectionW "SetupQueueDeleteSectionW" sptr, sptr, sptr, wstr
; res = SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)
; QueueHandle : void* -> "sptr"
; InfHandle : void* -> "sptr"
; ListInfHandle : void* optional -> "sptr"
; Section : LPCWSTR -> "wstr"; BOOL SetupQueueDeleteSectionW(void* QueueHandle, void* InfHandle, void* ListInfHandle, LPCWSTR Section)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueDeleteSectionW "SetupQueueDeleteSectionW" intptr, intptr, intptr, wstr
; res = SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)
; QueueHandle : void* -> "intptr"
; InfHandle : void* -> "intptr"
; ListInfHandle : void* optional -> "intptr"
; Section : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupQueueDeleteSectionW = setupapi.NewProc("SetupQueueDeleteSectionW")
)
// QueueHandle (void*), InfHandle (void*), ListInfHandle (void* optional), Section (LPCWSTR)
r1, _, err := procSetupQueueDeleteSectionW.Call(
uintptr(QueueHandle),
uintptr(InfHandle),
uintptr(ListInfHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Section))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupQueueDeleteSectionW(
QueueHandle: Pointer; // void*
InfHandle: Pointer; // void*
ListInfHandle: Pointer; // void* optional
Section: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueueDeleteSectionW';result := DllCall("SETUPAPI\SetupQueueDeleteSectionW"
, "Ptr", QueueHandle ; void*
, "Ptr", InfHandle ; void*
, "Ptr", ListInfHandle ; void* optional
, "WStr", Section ; LPCWSTR
, "Int") ; return: BOOL●SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section) = DLL("SETUPAPI.dll", "bool SetupQueueDeleteSectionW(void*, void*, void*, char*)")
# 呼び出し: SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)
# QueueHandle : void* -> "void*"
# InfHandle : void* -> "void*"
# ListInfHandle : void* optional -> "void*"
# Section : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupQueueDeleteSectionW(
QueueHandle: ?*anyopaque, // void*
InfHandle: ?*anyopaque, // void*
ListInfHandle: ?*anyopaque, // void* optional
Section: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupQueueDeleteSectionW(
QueueHandle: pointer, # void*
InfHandle: pointer, # void*
ListInfHandle: pointer, # void* optional
Section: WideCString # LPCWSTR
): int32 {.importc: "SetupQueueDeleteSectionW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupQueueDeleteSectionW(
void* QueueHandle, // void*
void* InfHandle, // void*
void* ListInfHandle, // void* optional
const(wchar)* Section // LPCWSTR
);ccall((:SetupQueueDeleteSectionW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cwstring),
QueueHandle, InfHandle, ListInfHandle, Section)
# QueueHandle : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# ListInfHandle : void* optional -> Ptr{Cvoid}
# Section : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueDeleteSectionW(
void* QueueHandle,
void* InfHandle,
void* ListInfHandle,
const uint16_t* Section);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)
-- QueueHandle : void*
-- InfHandle : void*
-- ListInfHandle : void* optional
-- Section : LPCWSTR
-- 構造体/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 SetupQueueDeleteSectionW = lib.func('__stdcall', 'SetupQueueDeleteSectionW', 'int32_t', ['void *', 'void *', 'void *', 'str16']);
// SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)
// QueueHandle : void* -> 'void *'
// InfHandle : void* -> 'void *'
// ListInfHandle : void* optional -> 'void *'
// Section : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupQueueDeleteSectionW: { parameters: ["pointer", "pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section)
// QueueHandle : void* -> "pointer"
// InfHandle : void* -> "pointer"
// ListInfHandle : void* optional -> "pointer"
// Section : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueDeleteSectionW(
void* QueueHandle,
void* InfHandle,
void* ListInfHandle,
const uint16_t* Section);
C, "SETUPAPI.dll");
// $ffi->SetupQueueDeleteSectionW(QueueHandle, InfHandle, ListInfHandle, Section);
// QueueHandle : void*
// InfHandle : void*
// ListInfHandle : void* optional
// Section : LPCWSTR
// 構造体/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 SetupQueueDeleteSectionW(
Pointer QueueHandle, // void*
Pointer InfHandle, // void*
Pointer ListInfHandle, // void* optional
WString Section // LPCWSTR
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupQueueDeleteSectionW = SetupQueueDeleteSectionW(
QueueHandle : Void*, # void*
InfHandle : Void*, # void*
ListInfHandle : Void*, # void* optional
Section : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupQueueDeleteSectionWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
typedef SetupQueueDeleteSectionWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
final SetupQueueDeleteSectionW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupQueueDeleteSectionWNative, SetupQueueDeleteSectionWDart>('SetupQueueDeleteSectionW');
// QueueHandle : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// ListInfHandle : void* optional -> Pointer<Void>
// Section : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupQueueDeleteSectionW(
QueueHandle: Pointer; // void*
InfHandle: Pointer; // void*
ListInfHandle: Pointer; // void* optional
Section: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueueDeleteSectionW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupQueueDeleteSectionW"
c_SetupQueueDeleteSectionW :: Ptr () -> Ptr () -> Ptr () -> CWString -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- InfHandle : void* -> Ptr ()
-- ListInfHandle : void* optional -> Ptr ()
-- Section : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupqueuedeletesectionw =
foreign "SetupQueueDeleteSectionW"
((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* ListInfHandle : void* optional -> (ptr void) *)
(* Section : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupQueueDeleteSectionW" setup-queue-delete-section-w :convention :stdcall) :int32
(queue-handle :pointer) ; void*
(inf-handle :pointer) ; void*
(list-inf-handle :pointer) ; void* optional
(section (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupQueueDeleteSectionW = Win32::API::More->new('SETUPAPI',
'BOOL SetupQueueDeleteSectionW(LPVOID QueueHandle, LPVOID InfHandle, LPVOID ListInfHandle, LPCWSTR Section)');
# my $ret = $SetupQueueDeleteSectionW->Call($QueueHandle, $InfHandle, $ListInfHandle, $Section);
# QueueHandle : void* -> LPVOID
# InfHandle : void* -> LPVOID
# ListInfHandle : void* optional -> LPVOID
# Section : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupQueueDeleteSectionA (ANSI版) — INFセクションのファイル群を削除操作としてキューに追加する(ANSI)。