ホーム › Devices.DeviceAndDriverInstallation › SetupOpenAppendInfFileW
SetupOpenAppendInfFileW
関数既存のINFハンドルに別のINFファイルを追加で開く(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupOpenAppendInfFileW(
LPCWSTR FileName, // optional
void* InfHandle,
DWORD* ErrorLine // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileName | LPCWSTR | inoptional | 追加で開くINFファイル名(Unicode)。NULLで対象INFのレイアウトファイルを開く。 |
| InfHandle | void* | in | 既に開いているINFハンドル。これに追加INFを連結する。 |
| ErrorLine | DWORD* | outoptional | 解析エラーが起きた行番号を受け取る出力ポインタ。NULL可。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupOpenAppendInfFileW(
LPCWSTR FileName, // optional
void* InfHandle,
DWORD* ErrorLine // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupOpenAppendInfFileW(
[MarshalAs(UnmanagedType.LPWStr)] string FileName, // LPCWSTR optional
IntPtr InfHandle, // void*
IntPtr ErrorLine // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupOpenAppendInfFileW(
<MarshalAs(UnmanagedType.LPWStr)> FileName As String, ' LPCWSTR optional
InfHandle As IntPtr, ' void*
ErrorLine As IntPtr ' DWORD* optional, out
) As Boolean
End Function' FileName : LPCWSTR optional
' InfHandle : void*
' ErrorLine : DWORD* optional, out
Declare PtrSafe Function SetupOpenAppendInfFileW Lib "setupapi" ( _
ByVal FileName As LongPtr, _
ByVal InfHandle As LongPtr, _
ByVal ErrorLine 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
SetupOpenAppendInfFileW = ctypes.windll.setupapi.SetupOpenAppendInfFileW
SetupOpenAppendInfFileW.restype = wintypes.BOOL
SetupOpenAppendInfFileW.argtypes = [
wintypes.LPCWSTR, # FileName : LPCWSTR optional
ctypes.POINTER(None), # InfHandle : void*
ctypes.POINTER(wintypes.DWORD), # ErrorLine : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupOpenAppendInfFileW = Fiddle::Function.new(
lib['SetupOpenAppendInfFileW'],
[
Fiddle::TYPE_VOIDP, # FileName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # ErrorLine : DWORD* optional, out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupOpenAppendInfFileW(
FileName: *const u16, // LPCWSTR optional
InfHandle: *mut (), // void*
ErrorLine: *mut u32 // DWORD* 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 SetupOpenAppendInfFileW([MarshalAs(UnmanagedType.LPWStr)] string FileName, IntPtr InfHandle, IntPtr ErrorLine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupOpenAppendInfFileW' -Namespace Win32 -PassThru
# $api::SetupOpenAppendInfFileW(FileName, InfHandle, ErrorLine)#uselib "SETUPAPI.dll"
#func global SetupOpenAppendInfFileW "SetupOpenAppendInfFileW" wptr, wptr, wptr
; SetupOpenAppendInfFileW FileName, InfHandle, varptr(ErrorLine) ; 戻り値は stat
; FileName : LPCWSTR optional -> "wptr"
; InfHandle : void* -> "wptr"
; ErrorLine : DWORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupOpenAppendInfFileW "SetupOpenAppendInfFileW" wstr, sptr, var ; res = SetupOpenAppendInfFileW(FileName, InfHandle, ErrorLine) ; FileName : LPCWSTR optional -> "wstr" ; InfHandle : void* -> "sptr" ; ErrorLine : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupOpenAppendInfFileW "SetupOpenAppendInfFileW" wstr, sptr, sptr ; res = SetupOpenAppendInfFileW(FileName, InfHandle, varptr(ErrorLine)) ; FileName : LPCWSTR optional -> "wstr" ; InfHandle : void* -> "sptr" ; ErrorLine : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupOpenAppendInfFileW(LPCWSTR FileName, void* InfHandle, DWORD* ErrorLine) #uselib "SETUPAPI.dll" #cfunc global SetupOpenAppendInfFileW "SetupOpenAppendInfFileW" wstr, intptr, var ; res = SetupOpenAppendInfFileW(FileName, InfHandle, ErrorLine) ; FileName : LPCWSTR optional -> "wstr" ; InfHandle : void* -> "intptr" ; ErrorLine : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupOpenAppendInfFileW(LPCWSTR FileName, void* InfHandle, DWORD* ErrorLine) #uselib "SETUPAPI.dll" #cfunc global SetupOpenAppendInfFileW "SetupOpenAppendInfFileW" wstr, intptr, intptr ; res = SetupOpenAppendInfFileW(FileName, InfHandle, varptr(ErrorLine)) ; FileName : LPCWSTR optional -> "wstr" ; InfHandle : void* -> "intptr" ; ErrorLine : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupOpenAppendInfFileW = setupapi.NewProc("SetupOpenAppendInfFileW")
)
// FileName (LPCWSTR optional), InfHandle (void*), ErrorLine (DWORD* optional, out)
r1, _, err := procSetupOpenAppendInfFileW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileName))),
uintptr(InfHandle),
uintptr(ErrorLine),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupOpenAppendInfFileW(
FileName: PWideChar; // LPCWSTR optional
InfHandle: Pointer; // void*
ErrorLine: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupOpenAppendInfFileW';result := DllCall("SETUPAPI\SetupOpenAppendInfFileW"
, "WStr", FileName ; LPCWSTR optional
, "Ptr", InfHandle ; void*
, "Ptr", ErrorLine ; DWORD* optional, out
, "Int") ; return: BOOL●SetupOpenAppendInfFileW(FileName, InfHandle, ErrorLine) = DLL("SETUPAPI.dll", "bool SetupOpenAppendInfFileW(char*, void*, void*)")
# 呼び出し: SetupOpenAppendInfFileW(FileName, InfHandle, ErrorLine)
# FileName : LPCWSTR optional -> "char*"
# InfHandle : void* -> "void*"
# ErrorLine : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。