ホーム › System.WindowsProgramming › OpenINFEngineA
OpenINFEngineA
関数INF処理エンジンを開いてハンドルを取得する(ANSI版)。
シグネチャ
// ADVPACK.dll (ANSI / -A)
#include <windows.h>
HRESULT OpenINFEngineA(
LPCSTR pszInfFilename,
LPCSTR pszInstallSection,
DWORD dwFlags,
void** phInf,
void* pvReserved
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszInfFilename | LPCSTR | in | 開く対象のINFファイル名を指す。 |
| pszInstallSection | LPCSTR | in | INFのインストールセクション名を指す。 |
| dwFlags | DWORD | in | エンジンの動作を制御するフラグ。 |
| phInf | void** | inout | 開いたINFエンジンのハンドルを受け取る変数へのポインタ。 |
| pvReserved | void* | inout | 予約済み。NULLを指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (ANSI / -A)
#include <windows.h>
HRESULT OpenINFEngineA(
LPCSTR pszInfFilename,
LPCSTR pszInstallSection,
DWORD dwFlags,
void** phInf,
void* pvReserved
);[DllImport("ADVPACK.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int OpenINFEngineA(
[MarshalAs(UnmanagedType.LPStr)] string pszInfFilename, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string pszInstallSection, // LPCSTR
uint dwFlags, // DWORD
IntPtr phInf, // void** in/out
IntPtr pvReserved // void* in/out
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function OpenINFEngineA(
<MarshalAs(UnmanagedType.LPStr)> pszInfFilename As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> pszInstallSection As String, ' LPCSTR
dwFlags As UInteger, ' DWORD
phInf As IntPtr, ' void** in/out
pvReserved As IntPtr ' void* in/out
) As Integer
End Function' pszInfFilename : LPCSTR
' pszInstallSection : LPCSTR
' dwFlags : DWORD
' phInf : void** in/out
' pvReserved : void* in/out
Declare PtrSafe Function OpenINFEngineA Lib "advpack" ( _
ByVal pszInfFilename As String, _
ByVal pszInstallSection As String, _
ByVal dwFlags As Long, _
ByVal phInf As LongPtr, _
ByVal pvReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OpenINFEngineA = ctypes.windll.advpack.OpenINFEngineA
OpenINFEngineA.restype = ctypes.c_int
OpenINFEngineA.argtypes = [
wintypes.LPCSTR, # pszInfFilename : LPCSTR
wintypes.LPCSTR, # pszInstallSection : LPCSTR
wintypes.DWORD, # dwFlags : DWORD
ctypes.c_void_p, # phInf : void** in/out
ctypes.POINTER(None), # pvReserved : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
OpenINFEngineA = Fiddle::Function.new(
lib['OpenINFEngineA'],
[
Fiddle::TYPE_VOIDP, # pszInfFilename : LPCSTR
Fiddle::TYPE_VOIDP, # pszInstallSection : LPCSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # phInf : void** in/out
Fiddle::TYPE_VOIDP, # pvReserved : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "advpack")]
extern "system" {
fn OpenINFEngineA(
pszInfFilename: *const u8, // LPCSTR
pszInstallSection: *const u8, // LPCSTR
dwFlags: u32, // DWORD
phInf: *mut *mut (), // void** in/out
pvReserved: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Ansi)]
public static extern int OpenINFEngineA([MarshalAs(UnmanagedType.LPStr)] string pszInfFilename, [MarshalAs(UnmanagedType.LPStr)] string pszInstallSection, uint dwFlags, IntPtr phInf, IntPtr pvReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_OpenINFEngineA' -Namespace Win32 -PassThru
# $api::OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)#uselib "ADVPACK.dll"
#func global OpenINFEngineA "OpenINFEngineA" sptr, sptr, sptr, sptr, sptr
; OpenINFEngineA pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved ; 戻り値は stat
; pszInfFilename : LPCSTR -> "sptr"
; pszInstallSection : LPCSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; phInf : void** in/out -> "sptr"
; pvReserved : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global OpenINFEngineA "OpenINFEngineA" str, str, int, sptr, sptr
; res = OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
; pszInfFilename : LPCSTR -> "str"
; pszInstallSection : LPCSTR -> "str"
; dwFlags : DWORD -> "int"
; phInf : void** in/out -> "sptr"
; pvReserved : void* in/out -> "sptr"; HRESULT OpenINFEngineA(LPCSTR pszInfFilename, LPCSTR pszInstallSection, DWORD dwFlags, void** phInf, void* pvReserved)
#uselib "ADVPACK.dll"
#cfunc global OpenINFEngineA "OpenINFEngineA" str, str, int, intptr, intptr
; res = OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
; pszInfFilename : LPCSTR -> "str"
; pszInstallSection : LPCSTR -> "str"
; dwFlags : DWORD -> "int"
; phInf : void** in/out -> "intptr"
; pvReserved : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procOpenINFEngineA = advpack.NewProc("OpenINFEngineA")
)
// pszInfFilename (LPCSTR), pszInstallSection (LPCSTR), dwFlags (DWORD), phInf (void** in/out), pvReserved (void* in/out)
r1, _, err := procOpenINFEngineA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszInfFilename))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszInstallSection))),
uintptr(dwFlags),
uintptr(phInf),
uintptr(pvReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction OpenINFEngineA(
pszInfFilename: PAnsiChar; // LPCSTR
pszInstallSection: PAnsiChar; // LPCSTR
dwFlags: DWORD; // DWORD
phInf: Pointer; // void** in/out
pvReserved: Pointer // void* in/out
): Integer; stdcall;
external 'ADVPACK.dll' name 'OpenINFEngineA';result := DllCall("ADVPACK\OpenINFEngineA"
, "AStr", pszInfFilename ; LPCSTR
, "AStr", pszInstallSection ; LPCSTR
, "UInt", dwFlags ; DWORD
, "Ptr", phInf ; void** in/out
, "Ptr", pvReserved ; void* in/out
, "Int") ; return: HRESULT●OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved) = DLL("ADVPACK.dll", "int OpenINFEngineA(char*, char*, dword, void*, void*)")
# 呼び出し: OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
# pszInfFilename : LPCSTR -> "char*"
# pszInstallSection : LPCSTR -> "char*"
# dwFlags : DWORD -> "dword"
# phInf : void** in/out -> "void*"
# pvReserved : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advpack" fn OpenINFEngineA(
pszInfFilename: [*c]const u8, // LPCSTR
pszInstallSection: [*c]const u8, // LPCSTR
dwFlags: u32, // DWORD
phInf: ?*anyopaque, // void** in/out
pvReserved: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc OpenINFEngineA(
pszInfFilename: cstring, # LPCSTR
pszInstallSection: cstring, # LPCSTR
dwFlags: uint32, # DWORD
phInf: pointer, # void** in/out
pvReserved: pointer # void* in/out
): int32 {.importc: "OpenINFEngineA", stdcall, dynlib: "ADVPACK.dll".}pragma(lib, "advpack");
extern(Windows)
int OpenINFEngineA(
const(char)* pszInfFilename, // LPCSTR
const(char)* pszInstallSection, // LPCSTR
uint dwFlags, // DWORD
void** phInf, // void** in/out
void* pvReserved // void* in/out
);ccall((:OpenINFEngineA, "ADVPACK.dll"), stdcall, Int32,
(Cstring, Cstring, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
# pszInfFilename : LPCSTR -> Cstring
# pszInstallSection : LPCSTR -> Cstring
# dwFlags : DWORD -> UInt32
# phInf : void** in/out -> Ptr{Cvoid}
# pvReserved : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t OpenINFEngineA(
const char* pszInfFilename,
const char* pszInstallSection,
uint32_t dwFlags,
void** phInf,
void* pvReserved);
]]
local advpack = ffi.load("advpack")
-- advpack.OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
-- pszInfFilename : LPCSTR
-- pszInstallSection : LPCSTR
-- dwFlags : DWORD
-- phInf : void** in/out
-- pvReserved : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVPACK.dll');
const OpenINFEngineA = lib.func('__stdcall', 'OpenINFEngineA', 'int32_t', ['str', 'str', 'uint32_t', 'void *', 'void *']);
// OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
// pszInfFilename : LPCSTR -> 'str'
// pszInstallSection : LPCSTR -> 'str'
// dwFlags : DWORD -> 'uint32_t'
// phInf : void** in/out -> 'void *'
// pvReserved : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVPACK.dll", {
OpenINFEngineA: { parameters: ["buffer", "buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
// pszInfFilename : LPCSTR -> "buffer"
// pszInstallSection : LPCSTR -> "buffer"
// dwFlags : DWORD -> "u32"
// phInf : void** in/out -> "pointer"
// pvReserved : void* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t OpenINFEngineA(
const char* pszInfFilename,
const char* pszInstallSection,
uint32_t dwFlags,
void** phInf,
void* pvReserved);
C, "ADVPACK.dll");
// $ffi->OpenINFEngineA(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved);
// pszInfFilename : LPCSTR
// pszInstallSection : LPCSTR
// dwFlags : DWORD
// phInf : void** in/out
// pvReserved : void* in/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 Advpack extends StdCallLibrary {
Advpack INSTANCE = Native.load("advpack", Advpack.class, W32APIOptions.ASCII_OPTIONS);
int OpenINFEngineA(
String pszInfFilename, // LPCSTR
String pszInstallSection, // LPCSTR
int dwFlags, // DWORD
Pointer phInf, // void** in/out
Pointer pvReserved // void* in/out
);
}@[Link("advpack")]
lib LibADVPACK
fun OpenINFEngineA = OpenINFEngineA(
pszInfFilename : UInt8*, # LPCSTR
pszInstallSection : UInt8*, # LPCSTR
dwFlags : UInt32, # DWORD
phInf : Void**, # void** in/out
pvReserved : Void* # void* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef OpenINFEngineANative = Int32 Function(Pointer<Utf8>, Pointer<Utf8>, Uint32, Pointer<Void>, Pointer<Void>);
typedef OpenINFEngineADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Void>, Pointer<Void>);
final OpenINFEngineA = DynamicLibrary.open('ADVPACK.dll')
.lookupFunction<OpenINFEngineANative, OpenINFEngineADart>('OpenINFEngineA');
// pszInfFilename : LPCSTR -> Pointer<Utf8>
// pszInstallSection : LPCSTR -> Pointer<Utf8>
// dwFlags : DWORD -> Uint32
// phInf : void** in/out -> Pointer<Void>
// pvReserved : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OpenINFEngineA(
pszInfFilename: PAnsiChar; // LPCSTR
pszInstallSection: PAnsiChar; // LPCSTR
dwFlags: DWORD; // DWORD
phInf: Pointer; // void** in/out
pvReserved: Pointer // void* in/out
): Integer; stdcall;
external 'ADVPACK.dll' name 'OpenINFEngineA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OpenINFEngineA"
c_OpenINFEngineA :: CString -> CString -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- pszInfFilename : LPCSTR -> CString
-- pszInstallSection : LPCSTR -> CString
-- dwFlags : DWORD -> Word32
-- phInf : void** in/out -> Ptr ()
-- pvReserved : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let openinfenginea =
foreign "OpenINFEngineA"
(string @-> string @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pszInfFilename : LPCSTR -> string *)
(* pszInstallSection : LPCSTR -> string *)
(* dwFlags : DWORD -> uint32_t *)
(* phInf : void** in/out -> (ptr void) *)
(* pvReserved : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advpack (t "ADVPACK.dll"))
(cffi:use-foreign-library advpack)
(cffi:defcfun ("OpenINFEngineA" open-infengine-a :convention :stdcall) :int32
(psz-inf-filename :string) ; LPCSTR
(psz-install-section :string) ; LPCSTR
(dw-flags :uint32) ; DWORD
(ph-inf :pointer) ; void** in/out
(pv-reserved :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $OpenINFEngineA = Win32::API::More->new('ADVPACK',
'int OpenINFEngineA(LPCSTR pszInfFilename, LPCSTR pszInstallSection, DWORD dwFlags, LPVOID phInf, LPVOID pvReserved)');
# my $ret = $OpenINFEngineA->Call($pszInfFilename, $pszInstallSection, $dwFlags, $phInf, $pvReserved);
# pszInfFilename : LPCSTR -> LPCSTR
# pszInstallSection : LPCSTR -> LPCSTR
# dwFlags : DWORD -> DWORD
# phInf : void** in/out -> LPVOID
# pvReserved : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f OpenINFEngineW (Unicode版) — INF処理エンジンを開いてハンドルを取得する(Unicode版)。