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

SetupQueueRenameSectionA

関数
INFセクションのファイル群を名前変更操作としてキューに追加する(ANSI)。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupQueueRenameSectionA(
    void* QueueHandle,
    void* InfHandle,
    void* ListInfHandle,   // optional
    LPCSTR Section
);

パラメーター

名前方向説明
QueueHandlevoid*in名前変更操作を登録するファイルキューのハンドル。
InfHandlevoid*in名前変更対象を記述したINFファイルのハンドル。
ListInfHandlevoid*inoptional追加情報を持つレイアウトINFのハンドル。NULL可。
SectionLPCSTRin名前変更対象を列挙したINFのセクション名(ANSI)。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupQueueRenameSectionA = ctypes.windll.setupapi.SetupQueueRenameSectionA
SetupQueueRenameSectionA.restype = wintypes.BOOL
SetupQueueRenameSectionA.argtypes = [
    ctypes.POINTER(None),  # QueueHandle : void*
    ctypes.POINTER(None),  # InfHandle : void*
    ctypes.POINTER(None),  # ListInfHandle : void* optional
    wintypes.LPCSTR,  # Section : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupQueueRenameSectionA = setupapi.NewProc("SetupQueueRenameSectionA")
)

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

extern "setupapi" fn SetupQueueRenameSectionA(
    QueueHandle: ?*anyopaque, // void*
    InfHandle: ?*anyopaque, // void*
    ListInfHandle: ?*anyopaque, // void* optional
    Section: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;
proc SetupQueueRenameSectionA(
    QueueHandle: pointer,  # void*
    InfHandle: pointer,  # void*
    ListInfHandle: pointer,  # void* optional
    Section: cstring  # LPCSTR
): int32 {.importc: "SetupQueueRenameSectionA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupQueueRenameSectionA(
    void* QueueHandle,   // void*
    void* InfHandle,   // void*
    void* ListInfHandle,   // void* optional
    const(char)* Section   // LPCSTR
);
ccall((:SetupQueueRenameSectionA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cstring),
      QueueHandle, InfHandle, ListInfHandle, Section)
# QueueHandle : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# ListInfHandle : void* optional -> Ptr{Cvoid}
# Section : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueRenameSectionA(
    void* QueueHandle,
    void* InfHandle,
    void* ListInfHandle,
    const char* Section);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueRenameSectionA(QueueHandle, InfHandle, ListInfHandle, Section)
-- QueueHandle : void*
-- InfHandle : void*
-- ListInfHandle : void* optional
-- Section : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupQueueRenameSectionA = lib.func('__stdcall', 'SetupQueueRenameSectionA', 'int32_t', ['void *', 'void *', 'void *', 'str']);
// SetupQueueRenameSectionA(QueueHandle, InfHandle, ListInfHandle, Section)
// QueueHandle : void* -> 'void *'
// InfHandle : void* -> 'void *'
// ListInfHandle : void* optional -> 'void *'
// Section : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupQueueRenameSectionA: { parameters: ["pointer", "pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.SetupQueueRenameSectionA(QueueHandle, InfHandle, ListInfHandle, Section)
// QueueHandle : void* -> "pointer"
// InfHandle : void* -> "pointer"
// ListInfHandle : void* optional -> "pointer"
// Section : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueRenameSectionA(
    void* QueueHandle,
    void* InfHandle,
    void* ListInfHandle,
    const char* Section);
C, "SETUPAPI.dll");
// $ffi->SetupQueueRenameSectionA(QueueHandle, InfHandle, ListInfHandle, Section);
// QueueHandle : void*
// InfHandle : void*
// ListInfHandle : void* optional
// Section : LPCSTR
// 構造体/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 SetupQueueRenameSectionA(
        Pointer QueueHandle,   // void*
        Pointer InfHandle,   // void*
        Pointer ListInfHandle,   // void* optional
        String Section   // LPCSTR
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupQueueRenameSectionA = SetupQueueRenameSectionA(
    QueueHandle : Void*,   # void*
    InfHandle : Void*,   # void*
    ListInfHandle : Void*,   # void* optional
    Section : UInt8*   # LPCSTR
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetupQueueRenameSectionANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>);
typedef SetupQueueRenameSectionADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>);
final SetupQueueRenameSectionA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupQueueRenameSectionANative, SetupQueueRenameSectionADart>('SetupQueueRenameSectionA');
// QueueHandle : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// ListInfHandle : void* optional -> Pointer<Void>
// Section : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupQueueRenameSectionA(
  QueueHandle: Pointer;   // void*
  InfHandle: Pointer;   // void*
  ListInfHandle: Pointer;   // void* optional
  Section: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupQueueRenameSectionA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupQueueRenameSectionA"
  c_SetupQueueRenameSectionA :: Ptr () -> Ptr () -> Ptr () -> CString -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- InfHandle : void* -> Ptr ()
-- ListInfHandle : void* optional -> Ptr ()
-- Section : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupqueuerenamesectiona =
  foreign "SetupQueueRenameSectionA"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> string @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* ListInfHandle : void* optional -> (ptr void) *)
(* Section : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)

(cffi:defcfun ("SetupQueueRenameSectionA" setup-queue-rename-section-a :convention :stdcall) :int32
  (queue-handle :pointer)   ; void*
  (inf-handle :pointer)   ; void*
  (list-inf-handle :pointer)   ; void* optional
  (section :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupQueueRenameSectionA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupQueueRenameSectionA(LPVOID QueueHandle, LPVOID InfHandle, LPVOID ListInfHandle, LPCSTR Section)');
# my $ret = $SetupQueueRenameSectionA->Call($QueueHandle, $InfHandle, $ListInfHandle, $Section);
# QueueHandle : void* -> LPVOID
# InfHandle : void* -> LPVOID
# ListInfHandle : void* optional -> LPVOID
# Section : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い