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

MsiProvideComponentW

関数
コンポーネントを必要に応じインストールしパスを返す(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiProvideComponentW(
    LPCWSTR szProduct,
    LPCWSTR szFeature,
    LPCWSTR szComponent,
    DWORD dwInstallMode,
    LPWSTR lpPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);

パラメーター

名前方向
szProductLPCWSTRin
szFeatureLPCWSTRin
szComponentLPCWSTRin
dwInstallModeDWORDin
lpPathBufLPWSTRoutoptional
pcchPathBufDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiProvideComponentW(
    LPCWSTR szProduct,
    LPCWSTR szFeature,
    LPCWSTR szComponent,
    DWORD dwInstallMode,
    LPWSTR lpPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiProvideComponentW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProduct,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szFeature,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szComponent,   // 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 MsiProvideComponentW(
    <MarshalAs(UnmanagedType.LPWStr)> szProduct As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szFeature As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szComponent 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
' szProduct : LPCWSTR
' szFeature : LPCWSTR
' szComponent : LPCWSTR
' dwInstallMode : DWORD
' lpPathBuf : LPWSTR optional, out
' pcchPathBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiProvideComponentW Lib "msi" ( _
    ByVal szProduct As LongPtr, _
    ByVal szFeature As LongPtr, _
    ByVal szComponent 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

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

// szProduct (LPCWSTR), szFeature (LPCWSTR), szComponent (LPCWSTR), dwInstallMode (DWORD), lpPathBuf (LPWSTR optional, out), pcchPathBuf (DWORD* optional, in/out)
r1, _, err := procMsiProvideComponentW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFeature))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szComponent))),
	uintptr(dwInstallMode),
	uintptr(lpPathBuf),
	uintptr(pcchPathBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiProvideComponentW(
  szProduct: PWideChar;   // LPCWSTR
  szFeature: PWideChar;   // LPCWSTR
  szComponent: PWideChar;   // LPCWSTR
  dwInstallMode: DWORD;   // DWORD
  lpPathBuf: PWideChar;   // LPWSTR optional, out
  pcchPathBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiProvideComponentW';
result := DllCall("msi\MsiProvideComponentW"
    , "WStr", szProduct   ; LPCWSTR
    , "WStr", szFeature   ; LPCWSTR
    , "WStr", szComponent   ; LPCWSTR
    , "UInt", dwInstallMode   ; DWORD
    , "Ptr", lpPathBuf   ; LPWSTR optional, out
    , "Ptr", pcchPathBuf   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiProvideComponentW(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf) = DLL("msi.dll", "dword MsiProvideComponentW(char*, char*, char*, dword, char*, void*)")
# 呼び出し: MsiProvideComponentW(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf)
# szProduct : LPCWSTR -> "char*"
# szFeature : LPCWSTR -> "char*"
# szComponent : 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 版の利用を推奨。