ホーム › Devices.DeviceAndDriverInstallation › SetupQueueRenameA
SetupQueueRenameA
関数ファイルキューに名前変更操作を追加する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupQueueRenameA(
void* QueueHandle,
LPCSTR SourcePath,
LPCSTR SourceFilename, // optional
LPCSTR TargetPath, // optional
LPCSTR TargetFilename
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| QueueHandle | void* | in | 名前変更操作を登録するファイルキューのハンドル。 |
| SourcePath | LPCSTR | in | 変更元ファイルのディレクトリパス(ANSI)。 |
| SourceFilename | LPCSTR | inoptional | 変更元のファイル名。NULLならSourcePath全体を対象とする。 |
| TargetPath | LPCSTR | inoptional | 変更先のディレクトリパス。NULLならSourcePathと同一とする。 |
| TargetFilename | LPCSTR | in | 変更後のファイル名(ANSI)。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupQueueRenameA(
void* QueueHandle,
LPCSTR SourcePath,
LPCSTR SourceFilename, // optional
LPCSTR TargetPath, // optional
LPCSTR TargetFilename
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupQueueRenameA(
IntPtr QueueHandle, // void*
[MarshalAs(UnmanagedType.LPStr)] string SourcePath, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string SourceFilename, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string TargetPath, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string TargetFilename // LPCSTR
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupQueueRenameA(
QueueHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> SourcePath As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> SourceFilename As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> TargetPath As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> TargetFilename As String ' LPCSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' QueueHandle : void*
' SourcePath : LPCSTR
' SourceFilename : LPCSTR optional
' TargetPath : LPCSTR optional
' TargetFilename : LPCSTR
Declare PtrSafe Function SetupQueueRenameA Lib "setupapi" ( _
ByVal QueueHandle As LongPtr, _
ByVal SourcePath As String, _
ByVal SourceFilename As String, _
ByVal TargetPath As String, _
ByVal TargetFilename As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupQueueRenameA = ctypes.windll.setupapi.SetupQueueRenameA
SetupQueueRenameA.restype = wintypes.BOOL
SetupQueueRenameA.argtypes = [
ctypes.POINTER(None), # QueueHandle : void*
wintypes.LPCSTR, # SourcePath : LPCSTR
wintypes.LPCSTR, # SourceFilename : LPCSTR optional
wintypes.LPCSTR, # TargetPath : LPCSTR optional
wintypes.LPCSTR, # TargetFilename : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupQueueRenameA = Fiddle::Function.new(
lib['SetupQueueRenameA'],
[
Fiddle::TYPE_VOIDP, # QueueHandle : void*
Fiddle::TYPE_VOIDP, # SourcePath : LPCSTR
Fiddle::TYPE_VOIDP, # SourceFilename : LPCSTR optional
Fiddle::TYPE_VOIDP, # TargetPath : LPCSTR optional
Fiddle::TYPE_VOIDP, # TargetFilename : LPCSTR
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupQueueRenameA(
QueueHandle: *mut (), // void*
SourcePath: *const u8, // LPCSTR
SourceFilename: *const u8, // LPCSTR optional
TargetPath: *const u8, // LPCSTR optional
TargetFilename: *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 SetupQueueRenameA(IntPtr QueueHandle, [MarshalAs(UnmanagedType.LPStr)] string SourcePath, [MarshalAs(UnmanagedType.LPStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPStr)] string TargetPath, [MarshalAs(UnmanagedType.LPStr)] string TargetFilename);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueRenameA' -Namespace Win32 -PassThru
# $api::SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)#uselib "SETUPAPI.dll"
#func global SetupQueueRenameA "SetupQueueRenameA" sptr, sptr, sptr, sptr, sptr
; SetupQueueRenameA QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename ; 戻り値は stat
; QueueHandle : void* -> "sptr"
; SourcePath : LPCSTR -> "sptr"
; SourceFilename : LPCSTR optional -> "sptr"
; TargetPath : LPCSTR optional -> "sptr"
; TargetFilename : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupQueueRenameA "SetupQueueRenameA" sptr, str, str, str, str
; res = SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
; QueueHandle : void* -> "sptr"
; SourcePath : LPCSTR -> "str"
; SourceFilename : LPCSTR optional -> "str"
; TargetPath : LPCSTR optional -> "str"
; TargetFilename : LPCSTR -> "str"; BOOL SetupQueueRenameA(void* QueueHandle, LPCSTR SourcePath, LPCSTR SourceFilename, LPCSTR TargetPath, LPCSTR TargetFilename)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueRenameA "SetupQueueRenameA" intptr, str, str, str, str
; res = SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
; QueueHandle : void* -> "intptr"
; SourcePath : LPCSTR -> "str"
; SourceFilename : LPCSTR optional -> "str"
; TargetPath : LPCSTR optional -> "str"
; TargetFilename : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupQueueRenameA = setupapi.NewProc("SetupQueueRenameA")
)
// QueueHandle (void*), SourcePath (LPCSTR), SourceFilename (LPCSTR optional), TargetPath (LPCSTR optional), TargetFilename (LPCSTR)
r1, _, err := procSetupQueueRenameA.Call(
uintptr(QueueHandle),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SourcePath))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceFilename))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetPath))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetFilename))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupQueueRenameA(
QueueHandle: Pointer; // void*
SourcePath: PAnsiChar; // LPCSTR
SourceFilename: PAnsiChar; // LPCSTR optional
TargetPath: PAnsiChar; // LPCSTR optional
TargetFilename: PAnsiChar // LPCSTR
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueueRenameA';result := DllCall("SETUPAPI\SetupQueueRenameA"
, "Ptr", QueueHandle ; void*
, "AStr", SourcePath ; LPCSTR
, "AStr", SourceFilename ; LPCSTR optional
, "AStr", TargetPath ; LPCSTR optional
, "AStr", TargetFilename ; LPCSTR
, "Int") ; return: BOOL●SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename) = DLL("SETUPAPI.dll", "bool SetupQueueRenameA(void*, char*, char*, char*, char*)")
# 呼び出し: SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
# QueueHandle : void* -> "void*"
# SourcePath : LPCSTR -> "char*"
# SourceFilename : LPCSTR optional -> "char*"
# TargetPath : LPCSTR optional -> "char*"
# TargetFilename : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "setupapi" fn SetupQueueRenameA(
QueueHandle: ?*anyopaque, // void*
SourcePath: [*c]const u8, // LPCSTR
SourceFilename: [*c]const u8, // LPCSTR optional
TargetPath: [*c]const u8, // LPCSTR optional
TargetFilename: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;proc SetupQueueRenameA(
QueueHandle: pointer, # void*
SourcePath: cstring, # LPCSTR
SourceFilename: cstring, # LPCSTR optional
TargetPath: cstring, # LPCSTR optional
TargetFilename: cstring # LPCSTR
): int32 {.importc: "SetupQueueRenameA", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupQueueRenameA(
void* QueueHandle, // void*
const(char)* SourcePath, // LPCSTR
const(char)* SourceFilename, // LPCSTR optional
const(char)* TargetPath, // LPCSTR optional
const(char)* TargetFilename // LPCSTR
);ccall((:SetupQueueRenameA, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cstring, Cstring, Cstring, Cstring),
QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
# QueueHandle : void* -> Ptr{Cvoid}
# SourcePath : LPCSTR -> Cstring
# SourceFilename : LPCSTR optional -> Cstring
# TargetPath : LPCSTR optional -> Cstring
# TargetFilename : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueRenameA(
void* QueueHandle,
const char* SourcePath,
const char* SourceFilename,
const char* TargetPath,
const char* TargetFilename);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
-- QueueHandle : void*
-- SourcePath : LPCSTR
-- SourceFilename : LPCSTR optional
-- TargetPath : LPCSTR optional
-- TargetFilename : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupQueueRenameA = lib.func('__stdcall', 'SetupQueueRenameA', 'int32_t', ['void *', 'str', 'str', 'str', 'str']);
// SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
// QueueHandle : void* -> 'void *'
// SourcePath : LPCSTR -> 'str'
// SourceFilename : LPCSTR optional -> 'str'
// TargetPath : LPCSTR optional -> 'str'
// TargetFilename : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupQueueRenameA: { parameters: ["pointer", "buffer", "buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename)
// QueueHandle : void* -> "pointer"
// SourcePath : LPCSTR -> "buffer"
// SourceFilename : LPCSTR optional -> "buffer"
// TargetPath : LPCSTR optional -> "buffer"
// TargetFilename : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueRenameA(
void* QueueHandle,
const char* SourcePath,
const char* SourceFilename,
const char* TargetPath,
const char* TargetFilename);
C, "SETUPAPI.dll");
// $ffi->SetupQueueRenameA(QueueHandle, SourcePath, SourceFilename, TargetPath, TargetFilename);
// QueueHandle : void*
// SourcePath : LPCSTR
// SourceFilename : LPCSTR optional
// TargetPath : LPCSTR optional
// TargetFilename : 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 SetupQueueRenameA(
Pointer QueueHandle, // void*
String SourcePath, // LPCSTR
String SourceFilename, // LPCSTR optional
String TargetPath, // LPCSTR optional
String TargetFilename // LPCSTR
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupQueueRenameA = SetupQueueRenameA(
QueueHandle : Void*, # void*
SourcePath : UInt8*, # LPCSTR
SourceFilename : UInt8*, # LPCSTR optional
TargetPath : UInt8*, # LPCSTR optional
TargetFilename : 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 SetupQueueRenameANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
typedef SetupQueueRenameADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
final SetupQueueRenameA = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupQueueRenameANative, SetupQueueRenameADart>('SetupQueueRenameA');
// QueueHandle : void* -> Pointer<Void>
// SourcePath : LPCSTR -> Pointer<Utf8>
// SourceFilename : LPCSTR optional -> Pointer<Utf8>
// TargetPath : LPCSTR optional -> Pointer<Utf8>
// TargetFilename : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupQueueRenameA(
QueueHandle: Pointer; // void*
SourcePath: PAnsiChar; // LPCSTR
SourceFilename: PAnsiChar; // LPCSTR optional
TargetPath: PAnsiChar; // LPCSTR optional
TargetFilename: PAnsiChar // LPCSTR
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueueRenameA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupQueueRenameA"
c_SetupQueueRenameA :: Ptr () -> CString -> CString -> CString -> CString -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- SourcePath : LPCSTR -> CString
-- SourceFilename : LPCSTR optional -> CString
-- TargetPath : LPCSTR optional -> CString
-- TargetFilename : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupqueuerenamea =
foreign "SetupQueueRenameA"
((ptr void) @-> string @-> string @-> string @-> string @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* SourcePath : LPCSTR -> string *)
(* SourceFilename : LPCSTR optional -> string *)
(* TargetPath : LPCSTR optional -> string *)
(* TargetFilename : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupQueueRenameA" setup-queue-rename-a :convention :stdcall) :int32
(queue-handle :pointer) ; void*
(source-path :string) ; LPCSTR
(source-filename :string) ; LPCSTR optional
(target-path :string) ; LPCSTR optional
(target-filename :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupQueueRenameA = Win32::API::More->new('SETUPAPI',
'BOOL SetupQueueRenameA(LPVOID QueueHandle, LPCSTR SourcePath, LPCSTR SourceFilename, LPCSTR TargetPath, LPCSTR TargetFilename)');
# my $ret = $SetupQueueRenameA->Call($QueueHandle, $SourcePath, $SourceFilename, $TargetPath, $TargetFilename);
# QueueHandle : void* -> LPVOID
# SourcePath : LPCSTR -> LPCSTR
# SourceFilename : LPCSTR optional -> LPCSTR
# TargetPath : LPCSTR optional -> LPCSTR
# TargetFilename : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SetupQueueRenameW (Unicode版) — ファイルキューに名前変更操作を追加する(Unicode)。