ホーム › Devices.DeviceAndDriverInstallation › SetupOpenAppendInfFileA
SetupOpenAppendInfFileA
関数既存のINFハンドルに別のINFファイルを追加で開く(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupOpenAppendInfFileA(
LPCSTR FileName, // optional
void* InfHandle,
DWORD* ErrorLine // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileName | LPCSTR | inoptional | 追加で開くINFファイル名(ANSI)。NULLで対象INFのレイアウトファイルを開く。 |
| InfHandle | void* | in | 既に開いているINFハンドル。これに追加INFを連結する。 |
| ErrorLine | DWORD* | outoptional | 解析エラーが起きた行番号を受け取る出力ポインタ。NULL可。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupOpenAppendInfFileA "SetupOpenAppendInfFileA" str, sptr, sptr ; res = SetupOpenAppendInfFileA(FileName, InfHandle, varptr(ErrorLine)) ; FileName : LPCSTR optional -> "str" ; InfHandle : void* -> "sptr" ; ErrorLine : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; BOOL SetupOpenAppendInfFileA(LPCSTR FileName, void* InfHandle, DWORD* ErrorLine) #uselib "SETUPAPI.dll" #cfunc global SetupOpenAppendInfFileA "SetupOpenAppendInfFileA" str, intptr, intptr ; res = SetupOpenAppendInfFileA(FileName, InfHandle, varptr(ErrorLine)) ; FileName : LPCSTR optional -> "str" ; InfHandle : void* -> "intptr" ; ErrorLine : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "setupapi" fn SetupOpenAppendInfFileA(
FileName: [*c]const u8, // LPCSTR optional
InfHandle: ?*anyopaque, // void*
ErrorLine: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc SetupOpenAppendInfFileA(
FileName: cstring, # LPCSTR optional
InfHandle: pointer, # void*
ErrorLine: ptr uint32 # DWORD* optional, out
): int32 {.importc: "SetupOpenAppendInfFileA", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupOpenAppendInfFileA(
const(char)* FileName, // LPCSTR optional
void* InfHandle, // void*
uint* ErrorLine // DWORD* optional, out
);ccall((:SetupOpenAppendInfFileA, "SETUPAPI.dll"), stdcall, Int32,
(Cstring, Ptr{Cvoid}, Ptr{UInt32}),
FileName, InfHandle, ErrorLine)
# FileName : LPCSTR optional -> Cstring
# InfHandle : void* -> Ptr{Cvoid}
# ErrorLine : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupOpenAppendInfFileA(
const char* FileName,
void* InfHandle,
uint32_t* ErrorLine);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine)
-- FileName : LPCSTR optional
-- InfHandle : void*
-- ErrorLine : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupOpenAppendInfFileA = lib.func('__stdcall', 'SetupOpenAppendInfFileA', 'int32_t', ['str', 'void *', 'uint32_t *']);
// SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine)
// FileName : LPCSTR optional -> 'str'
// InfHandle : void* -> 'void *'
// ErrorLine : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupOpenAppendInfFileA: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine)
// FileName : LPCSTR optional -> "buffer"
// InfHandle : void* -> "pointer"
// ErrorLine : DWORD* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupOpenAppendInfFileA(
const char* FileName,
void* InfHandle,
uint32_t* ErrorLine);
C, "SETUPAPI.dll");
// $ffi->SetupOpenAppendInfFileA(FileName, InfHandle, ErrorLine);
// FileName : LPCSTR optional
// InfHandle : void*
// ErrorLine : DWORD* optional, out
// 構造体/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 SetupOpenAppendInfFileA(
String FileName, // LPCSTR optional
Pointer InfHandle, // void*
IntByReference ErrorLine // DWORD* optional, out
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupOpenAppendInfFileA = SetupOpenAppendInfFileA(
FileName : UInt8*, # LPCSTR optional
InfHandle : Void*, # void*
ErrorLine : UInt32* # DWORD* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupOpenAppendInfFileANative = Int32 Function(Pointer<Utf8>, Pointer<Void>, Pointer<Uint32>);
typedef SetupOpenAppendInfFileADart = int Function(Pointer<Utf8>, Pointer<Void>, Pointer<Uint32>);
final SetupOpenAppendInfFileA = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupOpenAppendInfFileANative, SetupOpenAppendInfFileADart>('SetupOpenAppendInfFileA');
// FileName : LPCSTR optional -> Pointer<Utf8>
// InfHandle : void* -> Pointer<Void>
// ErrorLine : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupOpenAppendInfFileA(
FileName: PAnsiChar; // LPCSTR optional
InfHandle: Pointer; // void*
ErrorLine: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupOpenAppendInfFileA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupOpenAppendInfFileA"
c_SetupOpenAppendInfFileA :: CString -> Ptr () -> Ptr Word32 -> IO CInt
-- FileName : LPCSTR optional -> CString
-- InfHandle : void* -> Ptr ()
-- ErrorLine : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupopenappendinffilea =
foreign "SetupOpenAppendInfFileA"
(string @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* FileName : LPCSTR optional -> string *)
(* InfHandle : void* -> (ptr void) *)
(* ErrorLine : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupOpenAppendInfFileA" setup-open-append-inf-file-a :convention :stdcall) :int32
(file-name :string) ; LPCSTR optional
(inf-handle :pointer) ; void*
(error-line :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupOpenAppendInfFileA = Win32::API::More->new('SETUPAPI',
'BOOL SetupOpenAppendInfFileA(LPCSTR FileName, LPVOID InfHandle, LPVOID ErrorLine)');
# my $ret = $SetupOpenAppendInfFileA->Call($FileName, $InfHandle, $ErrorLine);
# FileName : LPCSTR optional -> LPCSTR
# InfHandle : void* -> LPVOID
# ErrorLine : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SetupOpenAppendInfFileW (Unicode版) — 既存のINFハンドルに別のINFファイルを追加で開く(Unicode)。