ホーム › Devices.DeviceAndDriverInstallation › SetupCopyOEMInfW
SetupCopyOEMInfW
関数OEM製のINFファイルをシステムのINFディレクトリにコピーする(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupCopyOEMInfW(
LPCWSTR SourceInfFileName,
LPCWSTR OEMSourceMediaLocation, // optional
OEM_SOURCE_MEDIA_TYPE OEMSourceMediaType,
SP_COPY_STYLE CopyStyle,
LPWSTR DestinationInfFileName, // optional
DWORD DestinationInfFileNameSize,
DWORD* RequiredSize, // optional
LPWSTR* DestinationInfFileNameComponent // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| SourceInfFileName | LPCWSTR | in |
| OEMSourceMediaLocation | LPCWSTR | inoptional |
| OEMSourceMediaType | OEM_SOURCE_MEDIA_TYPE | in |
| CopyStyle | SP_COPY_STYLE | in |
| DestinationInfFileName | LPWSTR | outoptional |
| DestinationInfFileNameSize | DWORD | in |
| RequiredSize | DWORD* | outoptional |
| DestinationInfFileNameComponent | LPWSTR* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupCopyOEMInfW(
LPCWSTR SourceInfFileName,
LPCWSTR OEMSourceMediaLocation, // optional
OEM_SOURCE_MEDIA_TYPE OEMSourceMediaType,
SP_COPY_STYLE CopyStyle,
LPWSTR DestinationInfFileName, // optional
DWORD DestinationInfFileNameSize,
DWORD* RequiredSize, // optional
LPWSTR* DestinationInfFileNameComponent // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupCopyOEMInfW(
[MarshalAs(UnmanagedType.LPWStr)] string SourceInfFileName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string OEMSourceMediaLocation, // LPCWSTR optional
uint OEMSourceMediaType, // OEM_SOURCE_MEDIA_TYPE
uint CopyStyle, // SP_COPY_STYLE
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DestinationInfFileName, // LPWSTR optional, out
uint DestinationInfFileNameSize, // DWORD
IntPtr RequiredSize, // DWORD* optional, out
IntPtr DestinationInfFileNameComponent // LPWSTR* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupCopyOEMInfW(
<MarshalAs(UnmanagedType.LPWStr)> SourceInfFileName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> OEMSourceMediaLocation As String, ' LPCWSTR optional
OEMSourceMediaType As UInteger, ' OEM_SOURCE_MEDIA_TYPE
CopyStyle As UInteger, ' SP_COPY_STYLE
<MarshalAs(UnmanagedType.LPWStr)> DestinationInfFileName As System.Text.StringBuilder, ' LPWSTR optional, out
DestinationInfFileNameSize As UInteger, ' DWORD
RequiredSize As IntPtr, ' DWORD* optional, out
DestinationInfFileNameComponent As IntPtr ' LPWSTR* optional, out
) As Boolean
End Function' SourceInfFileName : LPCWSTR
' OEMSourceMediaLocation : LPCWSTR optional
' OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE
' CopyStyle : SP_COPY_STYLE
' DestinationInfFileName : LPWSTR optional, out
' DestinationInfFileNameSize : DWORD
' RequiredSize : DWORD* optional, out
' DestinationInfFileNameComponent : LPWSTR* optional, out
Declare PtrSafe Function SetupCopyOEMInfW Lib "setupapi" ( _
ByVal SourceInfFileName As LongPtr, _
ByVal OEMSourceMediaLocation As LongPtr, _
ByVal OEMSourceMediaType As Long, _
ByVal CopyStyle As Long, _
ByVal DestinationInfFileName As LongPtr, _
ByVal DestinationInfFileNameSize As Long, _
ByVal RequiredSize As LongPtr, _
ByVal DestinationInfFileNameComponent 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
SetupCopyOEMInfW = ctypes.windll.setupapi.SetupCopyOEMInfW
SetupCopyOEMInfW.restype = wintypes.BOOL
SetupCopyOEMInfW.argtypes = [
wintypes.LPCWSTR, # SourceInfFileName : LPCWSTR
wintypes.LPCWSTR, # OEMSourceMediaLocation : LPCWSTR optional
wintypes.DWORD, # OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE
wintypes.DWORD, # CopyStyle : SP_COPY_STYLE
wintypes.LPWSTR, # DestinationInfFileName : LPWSTR optional, out
wintypes.DWORD, # DestinationInfFileNameSize : DWORD
ctypes.POINTER(wintypes.DWORD), # RequiredSize : DWORD* optional, out
ctypes.c_void_p, # DestinationInfFileNameComponent : LPWSTR* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupCopyOEMInfW = Fiddle::Function.new(
lib['SetupCopyOEMInfW'],
[
Fiddle::TYPE_VOIDP, # SourceInfFileName : LPCWSTR
Fiddle::TYPE_VOIDP, # OEMSourceMediaLocation : LPCWSTR optional
-Fiddle::TYPE_INT, # OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE
-Fiddle::TYPE_INT, # CopyStyle : SP_COPY_STYLE
Fiddle::TYPE_VOIDP, # DestinationInfFileName : LPWSTR optional, out
-Fiddle::TYPE_INT, # DestinationInfFileNameSize : DWORD
Fiddle::TYPE_VOIDP, # RequiredSize : DWORD* optional, out
Fiddle::TYPE_VOIDP, # DestinationInfFileNameComponent : LPWSTR* optional, out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupCopyOEMInfW(
SourceInfFileName: *const u16, // LPCWSTR
OEMSourceMediaLocation: *const u16, // LPCWSTR optional
OEMSourceMediaType: u32, // OEM_SOURCE_MEDIA_TYPE
CopyStyle: u32, // SP_COPY_STYLE
DestinationInfFileName: *mut u16, // LPWSTR optional, out
DestinationInfFileNameSize: u32, // DWORD
RequiredSize: *mut u32, // DWORD* optional, out
DestinationInfFileNameComponent: *mut *mut u16 // LPWSTR* optional, out
) -> 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 SetupCopyOEMInfW([MarshalAs(UnmanagedType.LPWStr)] string SourceInfFileName, [MarshalAs(UnmanagedType.LPWStr)] string OEMSourceMediaLocation, uint OEMSourceMediaType, uint CopyStyle, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DestinationInfFileName, uint DestinationInfFileNameSize, IntPtr RequiredSize, IntPtr DestinationInfFileNameComponent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupCopyOEMInfW' -Namespace Win32 -PassThru
# $api::SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, DestinationInfFileName, DestinationInfFileNameSize, RequiredSize, DestinationInfFileNameComponent)#uselib "SETUPAPI.dll"
#func global SetupCopyOEMInfW "SetupCopyOEMInfW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupCopyOEMInfW SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, varptr(DestinationInfFileName), DestinationInfFileNameSize, varptr(RequiredSize), varptr(DestinationInfFileNameComponent) ; 戻り値は stat
; SourceInfFileName : LPCWSTR -> "wptr"
; OEMSourceMediaLocation : LPCWSTR optional -> "wptr"
; OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE -> "wptr"
; CopyStyle : SP_COPY_STYLE -> "wptr"
; DestinationInfFileName : LPWSTR optional, out -> "wptr"
; DestinationInfFileNameSize : DWORD -> "wptr"
; RequiredSize : DWORD* optional, out -> "wptr"
; DestinationInfFileNameComponent : LPWSTR* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupCopyOEMInfW "SetupCopyOEMInfW" wstr, wstr, int, int, var, int, var, var ; res = SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, DestinationInfFileName, DestinationInfFileNameSize, RequiredSize, DestinationInfFileNameComponent) ; SourceInfFileName : LPCWSTR -> "wstr" ; OEMSourceMediaLocation : LPCWSTR optional -> "wstr" ; OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE -> "int" ; CopyStyle : SP_COPY_STYLE -> "int" ; DestinationInfFileName : LPWSTR optional, out -> "var" ; DestinationInfFileNameSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; DestinationInfFileNameComponent : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupCopyOEMInfW "SetupCopyOEMInfW" wstr, wstr, int, int, sptr, int, sptr, sptr ; res = SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, varptr(DestinationInfFileName), DestinationInfFileNameSize, varptr(RequiredSize), varptr(DestinationInfFileNameComponent)) ; SourceInfFileName : LPCWSTR -> "wstr" ; OEMSourceMediaLocation : LPCWSTR optional -> "wstr" ; OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE -> "int" ; CopyStyle : SP_COPY_STYLE -> "int" ; DestinationInfFileName : LPWSTR optional, out -> "sptr" ; DestinationInfFileNameSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "sptr" ; DestinationInfFileNameComponent : LPWSTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupCopyOEMInfW(LPCWSTR SourceInfFileName, LPCWSTR OEMSourceMediaLocation, OEM_SOURCE_MEDIA_TYPE OEMSourceMediaType, SP_COPY_STYLE CopyStyle, LPWSTR DestinationInfFileName, DWORD DestinationInfFileNameSize, DWORD* RequiredSize, LPWSTR* DestinationInfFileNameComponent) #uselib "SETUPAPI.dll" #cfunc global SetupCopyOEMInfW "SetupCopyOEMInfW" wstr, wstr, int, int, var, int, var, var ; res = SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, DestinationInfFileName, DestinationInfFileNameSize, RequiredSize, DestinationInfFileNameComponent) ; SourceInfFileName : LPCWSTR -> "wstr" ; OEMSourceMediaLocation : LPCWSTR optional -> "wstr" ; OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE -> "int" ; CopyStyle : SP_COPY_STYLE -> "int" ; DestinationInfFileName : LPWSTR optional, out -> "var" ; DestinationInfFileNameSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "var" ; DestinationInfFileNameComponent : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupCopyOEMInfW(LPCWSTR SourceInfFileName, LPCWSTR OEMSourceMediaLocation, OEM_SOURCE_MEDIA_TYPE OEMSourceMediaType, SP_COPY_STYLE CopyStyle, LPWSTR DestinationInfFileName, DWORD DestinationInfFileNameSize, DWORD* RequiredSize, LPWSTR* DestinationInfFileNameComponent) #uselib "SETUPAPI.dll" #cfunc global SetupCopyOEMInfW "SetupCopyOEMInfW" wstr, wstr, int, int, intptr, int, intptr, intptr ; res = SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, varptr(DestinationInfFileName), DestinationInfFileNameSize, varptr(RequiredSize), varptr(DestinationInfFileNameComponent)) ; SourceInfFileName : LPCWSTR -> "wstr" ; OEMSourceMediaLocation : LPCWSTR optional -> "wstr" ; OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE -> "int" ; CopyStyle : SP_COPY_STYLE -> "int" ; DestinationInfFileName : LPWSTR optional, out -> "intptr" ; DestinationInfFileNameSize : DWORD -> "int" ; RequiredSize : DWORD* optional, out -> "intptr" ; DestinationInfFileNameComponent : LPWSTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupCopyOEMInfW = setupapi.NewProc("SetupCopyOEMInfW")
)
// SourceInfFileName (LPCWSTR), OEMSourceMediaLocation (LPCWSTR optional), OEMSourceMediaType (OEM_SOURCE_MEDIA_TYPE), CopyStyle (SP_COPY_STYLE), DestinationInfFileName (LPWSTR optional, out), DestinationInfFileNameSize (DWORD), RequiredSize (DWORD* optional, out), DestinationInfFileNameComponent (LPWSTR* optional, out)
r1, _, err := procSetupCopyOEMInfW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceInfFileName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(OEMSourceMediaLocation))),
uintptr(OEMSourceMediaType),
uintptr(CopyStyle),
uintptr(DestinationInfFileName),
uintptr(DestinationInfFileNameSize),
uintptr(RequiredSize),
uintptr(DestinationInfFileNameComponent),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupCopyOEMInfW(
SourceInfFileName: PWideChar; // LPCWSTR
OEMSourceMediaLocation: PWideChar; // LPCWSTR optional
OEMSourceMediaType: DWORD; // OEM_SOURCE_MEDIA_TYPE
CopyStyle: DWORD; // SP_COPY_STYLE
DestinationInfFileName: PWideChar; // LPWSTR optional, out
DestinationInfFileNameSize: DWORD; // DWORD
RequiredSize: Pointer; // DWORD* optional, out
DestinationInfFileNameComponent: PPWideChar // LPWSTR* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupCopyOEMInfW';result := DllCall("SETUPAPI\SetupCopyOEMInfW"
, "WStr", SourceInfFileName ; LPCWSTR
, "WStr", OEMSourceMediaLocation ; LPCWSTR optional
, "UInt", OEMSourceMediaType ; OEM_SOURCE_MEDIA_TYPE
, "UInt", CopyStyle ; SP_COPY_STYLE
, "Ptr", DestinationInfFileName ; LPWSTR optional, out
, "UInt", DestinationInfFileNameSize ; DWORD
, "Ptr", RequiredSize ; DWORD* optional, out
, "Ptr", DestinationInfFileNameComponent ; LPWSTR* optional, out
, "Int") ; return: BOOL●SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, DestinationInfFileName, DestinationInfFileNameSize, RequiredSize, DestinationInfFileNameComponent) = DLL("SETUPAPI.dll", "bool SetupCopyOEMInfW(char*, char*, dword, dword, char*, dword, void*, void*)")
# 呼び出し: SetupCopyOEMInfW(SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType, CopyStyle, DestinationInfFileName, DestinationInfFileNameSize, RequiredSize, DestinationInfFileNameComponent)
# SourceInfFileName : LPCWSTR -> "char*"
# OEMSourceMediaLocation : LPCWSTR optional -> "char*"
# OEMSourceMediaType : OEM_SOURCE_MEDIA_TYPE -> "dword"
# CopyStyle : SP_COPY_STYLE -> "dword"
# DestinationInfFileName : LPWSTR optional, out -> "char*"
# DestinationInfFileNameSize : DWORD -> "dword"
# RequiredSize : DWORD* optional, out -> "void*"
# DestinationInfFileNameComponent : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。