Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › MsiProvideQualifiedComponentExW

MsiProvideQualifiedComponentExW

関数
製品を指定し修飾コンポーネントのパスを取得し、必要なら起動時インストールする。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiProvideQualifiedComponentExW(
    LPCWSTR szCategory,
    LPCWSTR szQualifier,
    DWORD dwInstallMode,
    LPCWSTR szProduct,   // optional
    DWORD dwUnused1,   // optional
    DWORD dwUnused2,   // optional
    LPWSTR lpPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);

パラメーター

名前方向説明
szCategoryLPCWSTRin要求するコンポーネントのコンポーネント ID を指定します。これはコンポーネント自体の GUID ではなく、 PublishComponent テーブルの ComponentId 列のように、正しい機能を提供するサーバーである場合があります。
szQualifierLPCWSTRinアドバタイズコンポーネントの一覧 ( PublishComponent テーブル) への修飾子を指定します。
dwInstallModeDWORDin

インストールモードを定義します。このパラメーターには次のいずれかの値を指定できます。

Value Meaning
INSTALLMODE_DEFAULT
コンポーネントを提供し、コンポーネントを提供するために必要なインストールを実行します。要求された機能、またはその親機能に含まれるコンポーネントのキーファイルが欠落している場合は、REINSTALLMODE_FILEMISSINGREINSTALLMODE_FILEOLDERVERSIONREINSTALLMODE_FILEVERIFYREINSTALLMODE_MACHINEDATAREINSTALLMODE_USERDATAREINSTALLMODE_SHORTCUT のフラグビットを設定した MsiReinstallFeature を使用して機能を再インストールします。
INSTALLMODE_EXISTING
機能が存在する場合にのみコンポーネントを提供します。存在しない場合は ERROR_FILE_NOT_FOUND を返します。

このモードでは、コンポーネントのキーファイルが存在することを検証します。

INSTALLMODE_NODETECTION
機能が存在する場合にのみコンポーネントを提供します。存在しない場合は ERROR_FILE_NOT_FOUND を返します。

このモードでは、コンポーネントが登録されていることのみを確認し、コンポーネントのキーファイルが存在することは検証しません。

INSTALLMODE_EXISTING
機能が存在する場合にのみコンポーネントを提供し、存在しない場合は ERROR_FILE_NOT_FOUND を返します。
REINSTALLMODE フラグの組み合わせ
このパラメーターを dwReinstallMode パラメーターとして使用して MsiReinstallFeature を呼び出して機能を再インストールし、その後コンポーネントを提供します。
INSTALLMODE_NOSOURCERESOLUTION
機能のインストール状態が INSTALLSTATE_LOCAL の場合にのみコンポーネントを提供します。機能のインストール状態が INSTALLSTATE_SOURCE の場合は ERROR_INSTALL_SOURCE_ABSENT を返します。それ以外の場合は ERROR_FILE_NOT_FOUND を返します。このモードでは、コンポーネントが登録されていることのみを確認し、キーファイルが存在することは検証しません。
szProductLPCWSTRinoptional修飾コンポーネントを発行した、一致させる製品を指定します。これが null の場合、この API は MsiProvideQualifiedComponent と同様に動作します。
dwUnused1DWORDoptional予約済みです。ゼロである必要があります。
dwUnused2DWORDoptional予約済みです。ゼロである必要があります。
lpPathBufLPWSTRoutoptionalコンポーネントへのパスを受け取る変数へのポインターです。このパラメーターは null にできます。
pcchPathBufDWORD*inoutoptional

lpPathBuf パラメーターが指すバッファーのサイズを文字数で指定する変数へのポインターです。入力時には、終端の null 文字用の領域を含むバッファーの全体サイズを指定します。渡されたバッファーが小さすぎる場合、返されるカウントには終端の null 文字は含まれません。

lpPathBuf が null の場合、pcchBuf も null にできます。

戻り値の型: DWORD

公式ドキュメント

MsiProvideQualifiedComponentEx 関数は、製品によって発行された修飾コンポーネントの完全なコンポーネントパスを返し、必要なインストールを実行します。(Unicode)

戻り値

Value Meaning
ERROR_INDEX_ABSENT
コンポーネント修飾子が無効か、存在しません。
ERROR_SUCCESS
関数は正常に完了しました。
ERROR_FILE_NOT_FOUND
機能が存在しないか、破損しています。このエラーは dwInstallMode = INSTALLMODE_EXISTING の場合に返されます。
ERROR_UNKNOWN_COMPONENT
指定されたコンポーネントは不明です。
アクションに関連するエラー
エラーコードを参照してください。
初期化エラー
初期化に関連するエラーが発生しました。

解説(Remarks)

MsiProvideQualifiedComponentEx 関数が成功すると、pcchPathBuf パラメーターには lpPathBuf 内の文字列の長さが格納されます。

破損したファイルや誤ったバージョンのファイルを含むコンポーネントを持つ機能は、ユーザーが明示的に再インストールするか、アプリケーションが MsiReinstallFeature を呼び出して再インストールする必要があります。

メモ

msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiProvideQualifiedComponentEx を定義しています。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、関数プロトタイプの規則を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiProvideQualifiedComponentExW(
    LPCWSTR szCategory,
    LPCWSTR szQualifier,
    DWORD dwInstallMode,
    LPCWSTR szProduct,   // optional
    DWORD dwUnused1,   // optional
    DWORD dwUnused2,   // optional
    LPWSTR lpPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiProvideQualifiedComponentExW(
    [MarshalAs(UnmanagedType.LPWStr)] string szCategory,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szQualifier,   // LPCWSTR
    uint dwInstallMode,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string szProduct,   // LPCWSTR optional
    uint dwUnused1,   // DWORD optional
    uint dwUnused2,   // DWORD optional
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPathBuf,   // LPWSTR optional, out
    IntPtr pcchPathBuf   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiProvideQualifiedComponentExW(
    <MarshalAs(UnmanagedType.LPWStr)> szCategory As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szQualifier As String,   ' LPCWSTR
    dwInstallMode As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> szProduct As String,   ' LPCWSTR optional
    dwUnused1 As UInteger,   ' DWORD optional
    dwUnused2 As UInteger,   ' DWORD optional
    <MarshalAs(UnmanagedType.LPWStr)> lpPathBuf As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcchPathBuf As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' szCategory : LPCWSTR
' szQualifier : LPCWSTR
' dwInstallMode : DWORD
' szProduct : LPCWSTR optional
' dwUnused1 : DWORD optional
' dwUnused2 : DWORD optional
' lpPathBuf : LPWSTR optional, out
' pcchPathBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiProvideQualifiedComponentExW Lib "msi" ( _
    ByVal szCategory As LongPtr, _
    ByVal szQualifier As LongPtr, _
    ByVal dwInstallMode As Long, _
    ByVal szProduct As LongPtr, _
    ByVal dwUnused1 As Long, _
    ByVal dwUnused2 As Long, _
    ByVal lpPathBuf As LongPtr, _
    ByVal pcchPathBuf 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

MsiProvideQualifiedComponentExW = ctypes.windll.msi.MsiProvideQualifiedComponentExW
MsiProvideQualifiedComponentExW.restype = wintypes.DWORD
MsiProvideQualifiedComponentExW.argtypes = [
    wintypes.LPCWSTR,  # szCategory : LPCWSTR
    wintypes.LPCWSTR,  # szQualifier : LPCWSTR
    wintypes.DWORD,  # dwInstallMode : DWORD
    wintypes.LPCWSTR,  # szProduct : LPCWSTR optional
    wintypes.DWORD,  # dwUnused1 : DWORD optional
    wintypes.DWORD,  # dwUnused2 : DWORD optional
    wintypes.LPWSTR,  # lpPathBuf : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchPathBuf : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiProvideQualifiedComponentExW = Fiddle::Function.new(
  lib['MsiProvideQualifiedComponentExW'],
  [
    Fiddle::TYPE_VOIDP,  # szCategory : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szQualifier : LPCWSTR
    -Fiddle::TYPE_INT,  # dwInstallMode : DWORD
    Fiddle::TYPE_VOIDP,  # szProduct : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwUnused1 : DWORD optional
    -Fiddle::TYPE_INT,  # dwUnused2 : DWORD optional
    Fiddle::TYPE_VOIDP,  # lpPathBuf : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchPathBuf : DWORD* optional, in/out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiProvideQualifiedComponentExW(
        szCategory: *const u16,  // LPCWSTR
        szQualifier: *const u16,  // LPCWSTR
        dwInstallMode: u32,  // DWORD
        szProduct: *const u16,  // LPCWSTR optional
        dwUnused1: u32,  // DWORD optional
        dwUnused2: u32,  // DWORD optional
        lpPathBuf: *mut u16,  // LPWSTR optional, out
        pcchPathBuf: *mut u32  // DWORD* optional, in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiProvideQualifiedComponentExW([MarshalAs(UnmanagedType.LPWStr)] string szCategory, [MarshalAs(UnmanagedType.LPWStr)] string szQualifier, uint dwInstallMode, [MarshalAs(UnmanagedType.LPWStr)] string szProduct, uint dwUnused1, uint dwUnused2, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPathBuf, IntPtr pcchPathBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiProvideQualifiedComponentExW' -Namespace Win32 -PassThru
# $api::MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
#uselib "msi.dll"
#func global MsiProvideQualifiedComponentExW "MsiProvideQualifiedComponentExW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; MsiProvideQualifiedComponentExW szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, varptr(lpPathBuf), varptr(pcchPathBuf)   ; 戻り値は stat
; szCategory : LPCWSTR -> "wptr"
; szQualifier : LPCWSTR -> "wptr"
; dwInstallMode : DWORD -> "wptr"
; szProduct : LPCWSTR optional -> "wptr"
; dwUnused1 : DWORD optional -> "wptr"
; dwUnused2 : DWORD optional -> "wptr"
; lpPathBuf : LPWSTR optional, out -> "wptr"
; pcchPathBuf : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiProvideQualifiedComponentExW "MsiProvideQualifiedComponentExW" wstr, wstr, int, wstr, int, int, var, var
; res = MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
; szCategory : LPCWSTR -> "wstr"
; szQualifier : LPCWSTR -> "wstr"
; dwInstallMode : DWORD -> "int"
; szProduct : LPCWSTR optional -> "wstr"
; dwUnused1 : DWORD optional -> "int"
; dwUnused2 : DWORD optional -> "int"
; lpPathBuf : LPWSTR optional, out -> "var"
; pcchPathBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiProvideQualifiedComponentExW(LPCWSTR szCategory, LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct, DWORD dwUnused1, DWORD dwUnused2, LPWSTR lpPathBuf, DWORD* pcchPathBuf)
#uselib "msi.dll"
#cfunc global MsiProvideQualifiedComponentExW "MsiProvideQualifiedComponentExW" wstr, wstr, int, wstr, int, int, var, var
; res = MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
; szCategory : LPCWSTR -> "wstr"
; szQualifier : LPCWSTR -> "wstr"
; dwInstallMode : DWORD -> "int"
; szProduct : LPCWSTR optional -> "wstr"
; dwUnused1 : DWORD optional -> "int"
; dwUnused2 : DWORD optional -> "int"
; lpPathBuf : LPWSTR optional, out -> "var"
; pcchPathBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiProvideQualifiedComponentExW = msi.NewProc("MsiProvideQualifiedComponentExW")
)

// szCategory (LPCWSTR), szQualifier (LPCWSTR), dwInstallMode (DWORD), szProduct (LPCWSTR optional), dwUnused1 (DWORD optional), dwUnused2 (DWORD optional), lpPathBuf (LPWSTR optional, out), pcchPathBuf (DWORD* optional, in/out)
r1, _, err := procMsiProvideQualifiedComponentExW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szCategory))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szQualifier))),
	uintptr(dwInstallMode),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
	uintptr(dwUnused1),
	uintptr(dwUnused2),
	uintptr(lpPathBuf),
	uintptr(pcchPathBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiProvideQualifiedComponentExW(
  szCategory: PWideChar;   // LPCWSTR
  szQualifier: PWideChar;   // LPCWSTR
  dwInstallMode: DWORD;   // DWORD
  szProduct: PWideChar;   // LPCWSTR optional
  dwUnused1: DWORD;   // DWORD optional
  dwUnused2: DWORD;   // DWORD optional
  lpPathBuf: PWideChar;   // LPWSTR optional, out
  pcchPathBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiProvideQualifiedComponentExW';
result := DllCall("msi\MsiProvideQualifiedComponentExW"
    , "WStr", szCategory   ; LPCWSTR
    , "WStr", szQualifier   ; LPCWSTR
    , "UInt", dwInstallMode   ; DWORD
    , "WStr", szProduct   ; LPCWSTR optional
    , "UInt", dwUnused1   ; DWORD optional
    , "UInt", dwUnused2   ; DWORD optional
    , "Ptr", lpPathBuf   ; LPWSTR optional, out
    , "Ptr", pcchPathBuf   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf) = DLL("msi.dll", "dword MsiProvideQualifiedComponentExW(char*, char*, dword, char*, dword, dword, char*, void*)")
# 呼び出し: MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
# szCategory : LPCWSTR -> "char*"
# szQualifier : LPCWSTR -> "char*"
# dwInstallMode : DWORD -> "dword"
# szProduct : LPCWSTR optional -> "char*"
# dwUnused1 : DWORD optional -> "dword"
# dwUnused2 : DWORD optional -> "dword"
# lpPathBuf : LPWSTR optional, out -> "char*"
# pcchPathBuf : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "msi" fn MsiProvideQualifiedComponentExW(
    szCategory: [*c]const u16, // LPCWSTR
    szQualifier: [*c]const u16, // LPCWSTR
    dwInstallMode: u32, // DWORD
    szProduct: [*c]const u16, // LPCWSTR optional
    dwUnused1: u32, // DWORD optional
    dwUnused2: u32, // DWORD optional
    lpPathBuf: [*c]u16, // LPWSTR optional, out
    pcchPathBuf: [*c]u32 // DWORD* optional, in/out
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc MsiProvideQualifiedComponentExW(
    szCategory: WideCString,  # LPCWSTR
    szQualifier: WideCString,  # LPCWSTR
    dwInstallMode: uint32,  # DWORD
    szProduct: WideCString,  # LPCWSTR optional
    dwUnused1: uint32,  # DWORD optional
    dwUnused2: uint32,  # DWORD optional
    lpPathBuf: ptr uint16,  # LPWSTR optional, out
    pcchPathBuf: ptr uint32  # DWORD* optional, in/out
): uint32 {.importc: "MsiProvideQualifiedComponentExW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "msi");
extern(Windows)
uint MsiProvideQualifiedComponentExW(
    const(wchar)* szCategory,   // LPCWSTR
    const(wchar)* szQualifier,   // LPCWSTR
    uint dwInstallMode,   // DWORD
    const(wchar)* szProduct,   // LPCWSTR optional
    uint dwUnused1,   // DWORD optional
    uint dwUnused2,   // DWORD optional
    wchar* lpPathBuf,   // LPWSTR optional, out
    uint* pcchPathBuf   // DWORD* optional, in/out
);
ccall((:MsiProvideQualifiedComponentExW, "msi.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, UInt32, Cwstring, UInt32, UInt32, Ptr{UInt16}, Ptr{UInt32}),
      szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
# szCategory : LPCWSTR -> Cwstring
# szQualifier : LPCWSTR -> Cwstring
# dwInstallMode : DWORD -> UInt32
# szProduct : LPCWSTR optional -> Cwstring
# dwUnused1 : DWORD optional -> UInt32
# dwUnused2 : DWORD optional -> UInt32
# lpPathBuf : LPWSTR optional, out -> Ptr{UInt16}
# pcchPathBuf : DWORD* optional, in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiProvideQualifiedComponentExW(
    const uint16_t* szCategory,
    const uint16_t* szQualifier,
    uint32_t dwInstallMode,
    const uint16_t* szProduct,
    uint32_t dwUnused1,
    uint32_t dwUnused2,
    uint16_t* lpPathBuf,
    uint32_t* pcchPathBuf);
]]
local msi = ffi.load("msi")
-- msi.MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
-- szCategory : LPCWSTR
-- szQualifier : LPCWSTR
-- dwInstallMode : DWORD
-- szProduct : LPCWSTR optional
-- dwUnused1 : DWORD optional
-- dwUnused2 : DWORD optional
-- lpPathBuf : LPWSTR optional, out
-- pcchPathBuf : DWORD* optional, 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('msi.dll');
const MsiProvideQualifiedComponentExW = lib.func('__stdcall', 'MsiProvideQualifiedComponentExW', 'uint32_t', ['str16', 'str16', 'uint32_t', 'str16', 'uint32_t', 'uint32_t', 'uint16_t *', 'uint32_t *']);
// MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
// szCategory : LPCWSTR -> 'str16'
// szQualifier : LPCWSTR -> 'str16'
// dwInstallMode : DWORD -> 'uint32_t'
// szProduct : LPCWSTR optional -> 'str16'
// dwUnused1 : DWORD optional -> 'uint32_t'
// dwUnused2 : DWORD optional -> 'uint32_t'
// lpPathBuf : LPWSTR optional, out -> 'uint16_t *'
// pcchPathBuf : DWORD* optional, in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msi.dll", {
  MsiProvideQualifiedComponentExW: { parameters: ["buffer", "buffer", "u32", "buffer", "u32", "u32", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf)
// szCategory : LPCWSTR -> "buffer"
// szQualifier : LPCWSTR -> "buffer"
// dwInstallMode : DWORD -> "u32"
// szProduct : LPCWSTR optional -> "buffer"
// dwUnused1 : DWORD optional -> "u32"
// dwUnused2 : DWORD optional -> "u32"
// lpPathBuf : LPWSTR optional, out -> "buffer"
// pcchPathBuf : DWORD* optional, in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiProvideQualifiedComponentExW(
    const uint16_t* szCategory,
    const uint16_t* szQualifier,
    uint32_t dwInstallMode,
    const uint16_t* szProduct,
    uint32_t dwUnused1,
    uint32_t dwUnused2,
    uint16_t* lpPathBuf,
    uint32_t* pcchPathBuf);
C, "msi.dll");
// $ffi->MsiProvideQualifiedComponentExW(szCategory, szQualifier, dwInstallMode, szProduct, dwUnused1, dwUnused2, lpPathBuf, pcchPathBuf);
// szCategory : LPCWSTR
// szQualifier : LPCWSTR
// dwInstallMode : DWORD
// szProduct : LPCWSTR optional
// dwUnused1 : DWORD optional
// dwUnused2 : DWORD optional
// lpPathBuf : LPWSTR optional, out
// pcchPathBuf : DWORD* optional, 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 Msi extends StdCallLibrary {
    Msi INSTANCE = Native.load("msi", Msi.class, W32APIOptions.UNICODE_OPTIONS);
    int MsiProvideQualifiedComponentExW(
        WString szCategory,   // LPCWSTR
        WString szQualifier,   // LPCWSTR
        int dwInstallMode,   // DWORD
        WString szProduct,   // LPCWSTR optional
        int dwUnused1,   // DWORD optional
        int dwUnused2,   // DWORD optional
        char[] lpPathBuf,   // LPWSTR optional, out
        IntByReference pcchPathBuf   // DWORD* optional, in/out
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("msi")]
lib Libmsi
  fun MsiProvideQualifiedComponentExW = MsiProvideQualifiedComponentExW(
    szCategory : UInt16*,   # LPCWSTR
    szQualifier : UInt16*,   # LPCWSTR
    dwInstallMode : UInt32,   # DWORD
    szProduct : UInt16*,   # LPCWSTR optional
    dwUnused1 : UInt32,   # DWORD optional
    dwUnused2 : UInt32,   # DWORD optional
    lpPathBuf : UInt16*,   # LPWSTR optional, out
    pcchPathBuf : UInt32*   # DWORD* optional, in/out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MsiProvideQualifiedComponentExWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Utf16>, Uint32, Uint32, Pointer<Utf16>, Pointer<Uint32>);
typedef MsiProvideQualifiedComponentExWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Utf16>, int, int, Pointer<Utf16>, Pointer<Uint32>);
final MsiProvideQualifiedComponentExW = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiProvideQualifiedComponentExWNative, MsiProvideQualifiedComponentExWDart>('MsiProvideQualifiedComponentExW');
// szCategory : LPCWSTR -> Pointer<Utf16>
// szQualifier : LPCWSTR -> Pointer<Utf16>
// dwInstallMode : DWORD -> Uint32
// szProduct : LPCWSTR optional -> Pointer<Utf16>
// dwUnused1 : DWORD optional -> Uint32
// dwUnused2 : DWORD optional -> Uint32
// lpPathBuf : LPWSTR optional, out -> Pointer<Utf16>
// pcchPathBuf : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiProvideQualifiedComponentExW(
  szCategory: PWideChar;   // LPCWSTR
  szQualifier: PWideChar;   // LPCWSTR
  dwInstallMode: DWORD;   // DWORD
  szProduct: PWideChar;   // LPCWSTR optional
  dwUnused1: DWORD;   // DWORD optional
  dwUnused2: DWORD;   // DWORD optional
  lpPathBuf: PWideChar;   // LPWSTR optional, out
  pcchPathBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiProvideQualifiedComponentExW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiProvideQualifiedComponentExW"
  c_MsiProvideQualifiedComponentExW :: CWString -> CWString -> Word32 -> CWString -> Word32 -> Word32 -> CWString -> Ptr Word32 -> IO Word32
-- szCategory : LPCWSTR -> CWString
-- szQualifier : LPCWSTR -> CWString
-- dwInstallMode : DWORD -> Word32
-- szProduct : LPCWSTR optional -> CWString
-- dwUnused1 : DWORD optional -> Word32
-- dwUnused2 : DWORD optional -> Word32
-- lpPathBuf : LPWSTR optional, out -> CWString
-- pcchPathBuf : DWORD* optional, in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msiprovidequalifiedcomponentexw =
  foreign "MsiProvideQualifiedComponentExW"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* szCategory : LPCWSTR -> (ptr uint16_t) *)
(* szQualifier : LPCWSTR -> (ptr uint16_t) *)
(* dwInstallMode : DWORD -> uint32_t *)
(* szProduct : LPCWSTR optional -> (ptr uint16_t) *)
(* dwUnused1 : DWORD optional -> uint32_t *)
(* dwUnused2 : DWORD optional -> uint32_t *)
(* lpPathBuf : LPWSTR optional, out -> (ptr uint16_t) *)
(* pcchPathBuf : DWORD* optional, in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)

(cffi:defcfun ("MsiProvideQualifiedComponentExW" msi-provide-qualified-component-ex-w :convention :stdcall) :uint32
  (sz-category (:string :encoding :utf-16le))   ; LPCWSTR
  (sz-qualifier (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-install-mode :uint32)   ; DWORD
  (sz-product (:string :encoding :utf-16le))   ; LPCWSTR optional
  (dw-unused1 :uint32)   ; DWORD optional
  (dw-unused2 :uint32)   ; DWORD optional
  (lp-path-buf :pointer)   ; LPWSTR optional, out
  (pcch-path-buf :pointer))   ; DWORD* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiProvideQualifiedComponentExW = Win32::API::More->new('msi',
    'DWORD MsiProvideQualifiedComponentExW(LPCWSTR szCategory, LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct, DWORD dwUnused1, DWORD dwUnused2, LPWSTR lpPathBuf, LPVOID pcchPathBuf)');
# my $ret = $MsiProvideQualifiedComponentExW->Call($szCategory, $szQualifier, $dwInstallMode, $szProduct, $dwUnused1, $dwUnused2, $lpPathBuf, $pcchPathBuf);
# szCategory : LPCWSTR -> LPCWSTR
# szQualifier : LPCWSTR -> LPCWSTR
# dwInstallMode : DWORD -> DWORD
# szProduct : LPCWSTR optional -> LPCWSTR
# dwUnused1 : DWORD optional -> DWORD
# dwUnused2 : DWORD optional -> DWORD
# lpPathBuf : LPWSTR optional, out -> LPWSTR
# pcchPathBuf : DWORD* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
類似 API