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

SetupOpenAppendInfFileA

関数
既存のINFハンドルに別のINFファイルを追加で開く(ANSI)。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupOpenAppendInfFileA(
    LPCSTR FileName,   // optional
    void* InfHandle,
    DWORD* ErrorLine   // optional
);

パラメーター

名前方向
FileNameLPCSTRinoptional
InfHandlevoid*in
ErrorLineDWORD*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupOpenAppendInfFileA = ctypes.windll.setupapi.SetupOpenAppendInfFileA
SetupOpenAppendInfFileA.restype = wintypes.BOOL
SetupOpenAppendInfFileA.argtypes = [
    wintypes.LPCSTR,  # FileName : LPCSTR 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')
SetupOpenAppendInfFileA = Fiddle::Function.new(
  lib['SetupOpenAppendInfFileA'],
  [
    Fiddle::TYPE_VOIDP,  # FileName : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # ErrorLine : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupOpenAppendInfFileA(
        FileName: *const u8,  // LPCSTR 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.Ansi, SetLastError = true)]
public static extern bool SetupOpenAppendInfFileA([MarshalAs(UnmanagedType.LPStr)] string FileName, IntPtr InfHandle, IntPtr ErrorLine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupOpenAppendInfFileA' -Namespace Win32 -PassThru
# $api::SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine)
#uselib "SETUPAPI.dll"
#func global SetupOpenAppendInfFileA "SetupOpenAppendInfFileA" sptr, sptr, sptr
; SetupOpenAppendInfFileA FileName, InfHandle, varptr(ErrorLine)   ; 戻り値は stat
; FileName : LPCSTR optional -> "sptr"
; InfHandle : void* -> "sptr"
; ErrorLine : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SETUPAPI.dll"
#cfunc global SetupOpenAppendInfFileA "SetupOpenAppendInfFileA" str, sptr, var
; res = SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine)
; FileName : LPCSTR optional -> "str"
; InfHandle : void* -> "sptr"
; ErrorLine : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetupOpenAppendInfFileA(LPCSTR FileName, void* InfHandle, DWORD* ErrorLine)
#uselib "SETUPAPI.dll"
#cfunc global SetupOpenAppendInfFileA "SetupOpenAppendInfFileA" str, intptr, var
; res = SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine)
; FileName : LPCSTR optional -> "str"
; InfHandle : void* -> "intptr"
; ErrorLine : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupOpenAppendInfFileA = setupapi.NewProc("SetupOpenAppendInfFileA")
)

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