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

MsiProvideQualifiedComponentW

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

シグネチャ

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

DWORD MsiProvideQualifiedComponentW(
    LPCWSTR szCategory,
    LPCWSTR szQualifier,
    DWORD dwInstallMode,
    LPWSTR lpPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);

パラメーター

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

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

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

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

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

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

REINSTALLMODE フラグの組み合わせ
このパラメーターを dwReinstallMode パラメーターとして使用して MsiReinstallFeature を呼び出して機能を再インストールし、その後コンポーネントを提供します。
INSTALLMODE_NOSOURCERESOLUTION
機能のインストール状態が INSTALLSTATE_LOCAL の場合にのみコンポーネントを提供します。機能のインストール状態が INSTALLSTATE_SOURCE の場合は ERROR_INSTALL_SOURCE_ABSENT を返します。それ以外の場合は ERROR_FILE_NOT_FOUND を返します。このモードはコンポーネントが登録されていることのみを確認し、キーファイルが存在することは検証しません。
lpPathBufLPWSTRoutoptionalコンポーネントへのパスを受け取る変数へのポインター。このパラメーターは null にすることができます。
pcchPathBufDWORD*inoutoptional

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

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

戻り値の型: DWORD

公式ドキュメント

MsiProvideQualifiedComponent 関数は、修飾コンポーネントの完全なコンポーネントパスを返し、必要なインストールを実行します。この関数は、必要に応じてソースの指定を要求し、機能の使用回数をインクリメントします。(Unicode)

戻り値

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

解説(Remarks)

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

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

メモ

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

出典・ライセンス: 上記「公式ドキュメント」の内容は 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 MsiProvideQualifiedComponentW(
    LPCWSTR szCategory,
    LPCWSTR szQualifier,
    DWORD dwInstallMode,
    LPWSTR lpPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiProvideQualifiedComponentW(
    [MarshalAs(UnmanagedType.LPWStr)] string szCategory,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szQualifier,   // LPCWSTR
    uint dwInstallMode,   // DWORD
    [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 MsiProvideQualifiedComponentW(
    <MarshalAs(UnmanagedType.LPWStr)> szCategory As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szQualifier As String,   ' LPCWSTR
    dwInstallMode As UInteger,   ' DWORD
    <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
' lpPathBuf : LPWSTR optional, out
' pcchPathBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiProvideQualifiedComponentW Lib "msi" ( _
    ByVal szCategory As LongPtr, _
    ByVal szQualifier As LongPtr, _
    ByVal dwInstallMode 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

MsiProvideQualifiedComponentW = ctypes.windll.msi.MsiProvideQualifiedComponentW
MsiProvideQualifiedComponentW.restype = wintypes.DWORD
MsiProvideQualifiedComponentW.argtypes = [
    wintypes.LPCWSTR,  # szCategory : LPCWSTR
    wintypes.LPCWSTR,  # szQualifier : LPCWSTR
    wintypes.DWORD,  # dwInstallMode : DWORD
    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')
MsiProvideQualifiedComponentW = Fiddle::Function.new(
  lib['MsiProvideQualifiedComponentW'],
  [
    Fiddle::TYPE_VOIDP,  # szCategory : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szQualifier : LPCWSTR
    -Fiddle::TYPE_INT,  # dwInstallMode : DWORD
    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 MsiProvideQualifiedComponentW(
        szCategory: *const u16,  // LPCWSTR
        szQualifier: *const u16,  // LPCWSTR
        dwInstallMode: u32,  // DWORD
        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 MsiProvideQualifiedComponentW([MarshalAs(UnmanagedType.LPWStr)] string szCategory, [MarshalAs(UnmanagedType.LPWStr)] string szQualifier, uint dwInstallMode, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPathBuf, IntPtr pcchPathBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiProvideQualifiedComponentW' -Namespace Win32 -PassThru
# $api::MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
#uselib "msi.dll"
#func global MsiProvideQualifiedComponentW "MsiProvideQualifiedComponentW" wptr, wptr, wptr, wptr, wptr
; MsiProvideQualifiedComponentW szCategory, szQualifier, dwInstallMode, varptr(lpPathBuf), varptr(pcchPathBuf)   ; 戻り値は stat
; szCategory : LPCWSTR -> "wptr"
; szQualifier : LPCWSTR -> "wptr"
; dwInstallMode : DWORD -> "wptr"
; lpPathBuf : LPWSTR optional, out -> "wptr"
; pcchPathBuf : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiProvideQualifiedComponentW "MsiProvideQualifiedComponentW" wstr, wstr, int, var, var
; res = MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
; szCategory : LPCWSTR -> "wstr"
; szQualifier : LPCWSTR -> "wstr"
; dwInstallMode : DWORD -> "int"
; lpPathBuf : LPWSTR optional, out -> "var"
; pcchPathBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiProvideQualifiedComponentW(LPCWSTR szCategory, LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf, DWORD* pcchPathBuf)
#uselib "msi.dll"
#cfunc global MsiProvideQualifiedComponentW "MsiProvideQualifiedComponentW" wstr, wstr, int, var, var
; res = MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
; szCategory : LPCWSTR -> "wstr"
; szQualifier : LPCWSTR -> "wstr"
; dwInstallMode : DWORD -> "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")
	procMsiProvideQualifiedComponentW = msi.NewProc("MsiProvideQualifiedComponentW")
)

// szCategory (LPCWSTR), szQualifier (LPCWSTR), dwInstallMode (DWORD), lpPathBuf (LPWSTR optional, out), pcchPathBuf (DWORD* optional, in/out)
r1, _, err := procMsiProvideQualifiedComponentW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szCategory))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szQualifier))),
	uintptr(dwInstallMode),
	uintptr(lpPathBuf),
	uintptr(pcchPathBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiProvideQualifiedComponentW(
  szCategory: PWideChar;   // LPCWSTR
  szQualifier: PWideChar;   // LPCWSTR
  dwInstallMode: DWORD;   // DWORD
  lpPathBuf: PWideChar;   // LPWSTR optional, out
  pcchPathBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiProvideQualifiedComponentW';
result := DllCall("msi\MsiProvideQualifiedComponentW"
    , "WStr", szCategory   ; LPCWSTR
    , "WStr", szQualifier   ; LPCWSTR
    , "UInt", dwInstallMode   ; DWORD
    , "Ptr", lpPathBuf   ; LPWSTR optional, out
    , "Ptr", pcchPathBuf   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf) = DLL("msi.dll", "dword MsiProvideQualifiedComponentW(char*, char*, dword, char*, void*)")
# 呼び出し: MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
# szCategory : LPCWSTR -> "char*"
# szQualifier : LPCWSTR -> "char*"
# dwInstallMode : DWORD -> "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 MsiProvideQualifiedComponentW(
    szCategory: [*c]const u16, // LPCWSTR
    szQualifier: [*c]const u16, // LPCWSTR
    dwInstallMode: u32, // DWORD
    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 MsiProvideQualifiedComponentW(
    szCategory: WideCString,  # LPCWSTR
    szQualifier: WideCString,  # LPCWSTR
    dwInstallMode: uint32,  # DWORD
    lpPathBuf: ptr uint16,  # LPWSTR optional, out
    pcchPathBuf: ptr uint32  # DWORD* optional, in/out
): uint32 {.importc: "MsiProvideQualifiedComponentW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "msi");
extern(Windows)
uint MsiProvideQualifiedComponentW(
    const(wchar)* szCategory,   // LPCWSTR
    const(wchar)* szQualifier,   // LPCWSTR
    uint dwInstallMode,   // DWORD
    wchar* lpPathBuf,   // LPWSTR optional, out
    uint* pcchPathBuf   // DWORD* optional, in/out
);
ccall((:MsiProvideQualifiedComponentW, "msi.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, UInt32, Ptr{UInt16}, Ptr{UInt32}),
      szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
# szCategory : LPCWSTR -> Cwstring
# szQualifier : LPCWSTR -> Cwstring
# dwInstallMode : DWORD -> 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 MsiProvideQualifiedComponentW(
    const uint16_t* szCategory,
    const uint16_t* szQualifier,
    uint32_t dwInstallMode,
    uint16_t* lpPathBuf,
    uint32_t* pcchPathBuf);
]]
local msi = ffi.load("msi")
-- msi.MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
-- szCategory : LPCWSTR
-- szQualifier : LPCWSTR
-- dwInstallMode : DWORD
-- 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 MsiProvideQualifiedComponentW = lib.func('__stdcall', 'MsiProvideQualifiedComponentW', 'uint32_t', ['str16', 'str16', 'uint32_t', 'uint16_t *', 'uint32_t *']);
// MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
// szCategory : LPCWSTR -> 'str16'
// szQualifier : LPCWSTR -> 'str16'
// dwInstallMode : DWORD -> '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", {
  MsiProvideQualifiedComponentW: { parameters: ["buffer", "buffer", "u32", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf)
// szCategory : LPCWSTR -> "buffer"
// szQualifier : LPCWSTR -> "buffer"
// dwInstallMode : DWORD -> "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 MsiProvideQualifiedComponentW(
    const uint16_t* szCategory,
    const uint16_t* szQualifier,
    uint32_t dwInstallMode,
    uint16_t* lpPathBuf,
    uint32_t* pcchPathBuf);
C, "msi.dll");
// $ffi->MsiProvideQualifiedComponentW(szCategory, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf);
// szCategory : LPCWSTR
// szQualifier : LPCWSTR
// dwInstallMode : DWORD
// 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 MsiProvideQualifiedComponentW(
        WString szCategory,   // LPCWSTR
        WString szQualifier,   // LPCWSTR
        int dwInstallMode,   // DWORD
        char[] lpPathBuf,   // LPWSTR optional, out
        IntByReference pcchPathBuf   // DWORD* optional, in/out
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("msi")]
lib Libmsi
  fun MsiProvideQualifiedComponentW = MsiProvideQualifiedComponentW(
    szCategory : UInt16*,   # LPCWSTR
    szQualifier : UInt16*,   # LPCWSTR
    dwInstallMode : UInt32,   # DWORD
    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 MsiProvideQualifiedComponentWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Uint32>);
typedef MsiProvideQualifiedComponentWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Uint32>);
final MsiProvideQualifiedComponentW = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiProvideQualifiedComponentWNative, MsiProvideQualifiedComponentWDart>('MsiProvideQualifiedComponentW');
// szCategory : LPCWSTR -> Pointer<Utf16>
// szQualifier : LPCWSTR -> Pointer<Utf16>
// dwInstallMode : DWORD -> Uint32
// lpPathBuf : LPWSTR optional, out -> Pointer<Utf16>
// pcchPathBuf : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiProvideQualifiedComponentW(
  szCategory: PWideChar;   // LPCWSTR
  szQualifier: PWideChar;   // LPCWSTR
  dwInstallMode: DWORD;   // DWORD
  lpPathBuf: PWideChar;   // LPWSTR optional, out
  pcchPathBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiProvideQualifiedComponentW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiProvideQualifiedComponentW"
  c_MsiProvideQualifiedComponentW :: CWString -> CWString -> Word32 -> CWString -> Ptr Word32 -> IO Word32
-- szCategory : LPCWSTR -> CWString
-- szQualifier : LPCWSTR -> CWString
-- dwInstallMode : DWORD -> 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 msiprovidequalifiedcomponentw =
  foreign "MsiProvideQualifiedComponentW"
    ((ptr uint16_t) @-> (ptr uint16_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 *)
(* 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 ("MsiProvideQualifiedComponentW" msi-provide-qualified-component-w :convention :stdcall) :uint32
  (sz-category (:string :encoding :utf-16le))   ; LPCWSTR
  (sz-qualifier (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-install-mode :uint32)   ; DWORD
  (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 $MsiProvideQualifiedComponentW = Win32::API::More->new('msi',
    'DWORD MsiProvideQualifiedComponentW(LPCWSTR szCategory, LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf, LPVOID pcchPathBuf)');
# my $ret = $MsiProvideQualifiedComponentW->Call($szCategory, $szQualifier, $dwInstallMode, $lpPathBuf, $pcchPathBuf);
# szCategory : LPCWSTR -> LPCWSTR
# szQualifier : LPCWSTR -> LPCWSTR
# dwInstallMode : DWORD -> 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