ホーム › System.WindowsProgramming › OpenINFEngineW
OpenINFEngineW
関数INF処理エンジンを開いてハンドルを取得する(Unicode版)。
シグネチャ
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT OpenINFEngineW(
LPCWSTR pszInfFilename,
LPCWSTR pszInstallSection,
DWORD dwFlags,
void** phInf,
void* pvReserved
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszInfFilename | LPCWSTR | in | 開く対象のINFファイル名を指す。 |
| pszInstallSection | LPCWSTR | in | INFのインストールセクション名を指す。 |
| dwFlags | DWORD | in | エンジンの動作を制御するフラグ。 |
| phInf | void** | inout | 開いたINFエンジンのハンドルを受け取る変数へのポインタ。 |
| pvReserved | void* | inout | 予約済み。NULLを指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT OpenINFEngineW(
LPCWSTR pszInfFilename,
LPCWSTR pszInstallSection,
DWORD dwFlags,
void** phInf,
void* pvReserved
);[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int OpenINFEngineW(
[MarshalAs(UnmanagedType.LPWStr)] string pszInfFilename, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszInstallSection, // LPCWSTR
uint dwFlags, // DWORD
IntPtr phInf, // void** in/out
IntPtr pvReserved // void* in/out
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function OpenINFEngineW(
<MarshalAs(UnmanagedType.LPWStr)> pszInfFilename As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszInstallSection As String, ' LPCWSTR
dwFlags As UInteger, ' DWORD
phInf As IntPtr, ' void** in/out
pvReserved As IntPtr ' void* in/out
) As Integer
End Function' pszInfFilename : LPCWSTR
' pszInstallSection : LPCWSTR
' dwFlags : DWORD
' phInf : void** in/out
' pvReserved : void* in/out
Declare PtrSafe Function OpenINFEngineW Lib "advpack" ( _
ByVal pszInfFilename As LongPtr, _
ByVal pszInstallSection As LongPtr, _
ByVal dwFlags As Long, _
ByVal phInf As LongPtr, _
ByVal pvReserved 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
OpenINFEngineW = ctypes.windll.advpack.OpenINFEngineW
OpenINFEngineW.restype = ctypes.c_int
OpenINFEngineW.argtypes = [
wintypes.LPCWSTR, # pszInfFilename : LPCWSTR
wintypes.LPCWSTR, # pszInstallSection : LPCWSTR
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')
OpenINFEngineW = Fiddle::Function.new(
lib['OpenINFEngineW'],
[
Fiddle::TYPE_VOIDP, # pszInfFilename : LPCWSTR
Fiddle::TYPE_VOIDP, # pszInstallSection : LPCWSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # phInf : void** in/out
Fiddle::TYPE_VOIDP, # pvReserved : void* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advpack")]
extern "system" {
fn OpenINFEngineW(
pszInfFilename: *const u16, // LPCWSTR
pszInstallSection: *const u16, // LPCWSTR
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.Unicode)]
public static extern int OpenINFEngineW([MarshalAs(UnmanagedType.LPWStr)] string pszInfFilename, [MarshalAs(UnmanagedType.LPWStr)] string pszInstallSection, uint dwFlags, IntPtr phInf, IntPtr pvReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_OpenINFEngineW' -Namespace Win32 -PassThru
# $api::OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)#uselib "ADVPACK.dll"
#func global OpenINFEngineW "OpenINFEngineW" wptr, wptr, wptr, wptr, wptr
; OpenINFEngineW pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved ; 戻り値は stat
; pszInfFilename : LPCWSTR -> "wptr"
; pszInstallSection : LPCWSTR -> "wptr"
; dwFlags : DWORD -> "wptr"
; phInf : void** in/out -> "wptr"
; pvReserved : void* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global OpenINFEngineW "OpenINFEngineW" wstr, wstr, int, sptr, sptr
; res = OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
; pszInfFilename : LPCWSTR -> "wstr"
; pszInstallSection : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; phInf : void** in/out -> "sptr"
; pvReserved : void* in/out -> "sptr"; HRESULT OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, DWORD dwFlags, void** phInf, void* pvReserved)
#uselib "ADVPACK.dll"
#cfunc global OpenINFEngineW "OpenINFEngineW" wstr, wstr, int, intptr, intptr
; res = OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
; pszInfFilename : LPCWSTR -> "wstr"
; pszInstallSection : LPCWSTR -> "wstr"
; 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")
procOpenINFEngineW = advpack.NewProc("OpenINFEngineW")
)
// pszInfFilename (LPCWSTR), pszInstallSection (LPCWSTR), dwFlags (DWORD), phInf (void** in/out), pvReserved (void* in/out)
r1, _, err := procOpenINFEngineW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszInfFilename))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszInstallSection))),
uintptr(dwFlags),
uintptr(phInf),
uintptr(pvReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction OpenINFEngineW(
pszInfFilename: PWideChar; // LPCWSTR
pszInstallSection: PWideChar; // LPCWSTR
dwFlags: DWORD; // DWORD
phInf: Pointer; // void** in/out
pvReserved: Pointer // void* in/out
): Integer; stdcall;
external 'ADVPACK.dll' name 'OpenINFEngineW';result := DllCall("ADVPACK\OpenINFEngineW"
, "WStr", pszInfFilename ; LPCWSTR
, "WStr", pszInstallSection ; LPCWSTR
, "UInt", dwFlags ; DWORD
, "Ptr", phInf ; void** in/out
, "Ptr", pvReserved ; void* in/out
, "Int") ; return: HRESULT●OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved) = DLL("ADVPACK.dll", "int OpenINFEngineW(char*, char*, dword, void*, void*)")
# 呼び出し: OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
# pszInfFilename : LPCWSTR -> "char*"
# pszInstallSection : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# phInf : void** in/out -> "void*"
# pvReserved : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "advpack" fn OpenINFEngineW(
pszInfFilename: [*c]const u16, // LPCWSTR
pszInstallSection: [*c]const u16, // LPCWSTR
dwFlags: u32, // DWORD
phInf: ?*anyopaque, // void** in/out
pvReserved: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc OpenINFEngineW(
pszInfFilename: WideCString, # LPCWSTR
pszInstallSection: WideCString, # LPCWSTR
dwFlags: uint32, # DWORD
phInf: pointer, # void** in/out
pvReserved: pointer # void* in/out
): int32 {.importc: "OpenINFEngineW", stdcall, dynlib: "ADVPACK.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "advpack");
extern(Windows)
int OpenINFEngineW(
const(wchar)* pszInfFilename, // LPCWSTR
const(wchar)* pszInstallSection, // LPCWSTR
uint dwFlags, // DWORD
void** phInf, // void** in/out
void* pvReserved // void* in/out
);ccall((:OpenINFEngineW, "ADVPACK.dll"), stdcall, Int32,
(Cwstring, Cwstring, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
# pszInfFilename : LPCWSTR -> Cwstring
# pszInstallSection : LPCWSTR -> Cwstring
# dwFlags : DWORD -> UInt32
# phInf : void** in/out -> Ptr{Cvoid}
# pvReserved : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t OpenINFEngineW(
const uint16_t* pszInfFilename,
const uint16_t* pszInstallSection,
uint32_t dwFlags,
void** phInf,
void* pvReserved);
]]
local advpack = ffi.load("advpack")
-- advpack.OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
-- pszInfFilename : LPCWSTR
-- pszInstallSection : LPCWSTR
-- dwFlags : DWORD
-- phInf : void** in/out
-- pvReserved : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ADVPACK.dll');
const OpenINFEngineW = lib.func('__stdcall', 'OpenINFEngineW', 'int32_t', ['str16', 'str16', 'uint32_t', 'void *', 'void *']);
// OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
// pszInfFilename : LPCWSTR -> 'str16'
// pszInstallSection : LPCWSTR -> 'str16'
// dwFlags : DWORD -> 'uint32_t'
// phInf : void** in/out -> 'void *'
// pvReserved : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVPACK.dll", {
OpenINFEngineW: { parameters: ["buffer", "buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved)
// pszInfFilename : LPCWSTR -> "buffer"
// pszInstallSection : LPCWSTR -> "buffer"
// dwFlags : DWORD -> "u32"
// phInf : void** in/out -> "pointer"
// pvReserved : void* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t OpenINFEngineW(
const uint16_t* pszInfFilename,
const uint16_t* pszInstallSection,
uint32_t dwFlags,
void** phInf,
void* pvReserved);
C, "ADVPACK.dll");
// $ffi->OpenINFEngineW(pszInfFilename, pszInstallSection, dwFlags, phInf, pvReserved);
// pszInfFilename : LPCWSTR
// pszInstallSection : LPCWSTR
// 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.UNICODE_OPTIONS);
int OpenINFEngineW(
WString pszInfFilename, // LPCWSTR
WString pszInstallSection, // LPCWSTR
int dwFlags, // DWORD
Pointer phInf, // void** in/out
Pointer pvReserved // void* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("advpack")]
lib LibADVPACK
fun OpenINFEngineW = OpenINFEngineW(
pszInfFilename : UInt16*, # LPCWSTR
pszInstallSection : UInt16*, # LPCWSTR
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 OpenINFEngineWNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Void>, Pointer<Void>);
typedef OpenINFEngineWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Void>, Pointer<Void>);
final OpenINFEngineW = DynamicLibrary.open('ADVPACK.dll')
.lookupFunction<OpenINFEngineWNative, OpenINFEngineWDart>('OpenINFEngineW');
// pszInfFilename : LPCWSTR -> Pointer<Utf16>
// pszInstallSection : LPCWSTR -> Pointer<Utf16>
// dwFlags : DWORD -> Uint32
// phInf : void** in/out -> Pointer<Void>
// pvReserved : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OpenINFEngineW(
pszInfFilename: PWideChar; // LPCWSTR
pszInstallSection: PWideChar; // LPCWSTR
dwFlags: DWORD; // DWORD
phInf: Pointer; // void** in/out
pvReserved: Pointer // void* in/out
): Integer; stdcall;
external 'ADVPACK.dll' name 'OpenINFEngineW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OpenINFEngineW"
c_OpenINFEngineW :: CWString -> CWString -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- pszInfFilename : LPCWSTR -> CWString
-- pszInstallSection : LPCWSTR -> CWString
-- 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 openinfenginew =
foreign "OpenINFEngineW"
((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pszInfFilename : LPCWSTR -> (ptr uint16_t) *)
(* pszInstallSection : LPCWSTR -> (ptr uint16_t) *)
(* 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 ("OpenINFEngineW" open-infengine-w :convention :stdcall) :int32
(psz-inf-filename (:string :encoding :utf-16le)) ; LPCWSTR
(psz-install-section (:string :encoding :utf-16le)) ; LPCWSTR
(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 $OpenINFEngineW = Win32::API::More->new('ADVPACK',
'int OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, DWORD dwFlags, LPVOID phInf, LPVOID pvReserved)');
# my $ret = $OpenINFEngineW->Call($pszInfFilename, $pszInstallSection, $dwFlags, $phInf, $pvReserved);
# pszInfFilename : LPCWSTR -> LPCWSTR
# pszInstallSection : LPCWSTR -> LPCWSTR
# dwFlags : DWORD -> DWORD
# phInf : void** in/out -> LPVOID
# pvReserved : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f OpenINFEngineA (ANSI版) — INF処理エンジンを開いてハンドルを取得する(ANSI版)。