ホーム › System.ApplicationInstallationAndServicing › MsiProvideComponentA
MsiProvideComponentA
関数コンポーネントを必要に応じインストールしパスを返す(ANSI版)。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiProvideComponentA(
LPCSTR szProduct,
LPCSTR szFeature,
LPCSTR szComponent,
DWORD dwInstallMode,
LPSTR lpPathBuf, // optional
DWORD* pcchPathBuf // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szProduct | LPCSTR | in |
| szFeature | LPCSTR | in |
| szComponent | LPCSTR | in |
| dwInstallMode | DWORD | in |
| lpPathBuf | LPSTR | outoptional |
| pcchPathBuf | DWORD* | inoutoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiProvideComponentA(
LPCSTR szProduct,
LPCSTR szFeature,
LPCSTR szComponent,
DWORD dwInstallMode,
LPSTR lpPathBuf, // optional
DWORD* pcchPathBuf // optional
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiProvideComponentA(
[MarshalAs(UnmanagedType.LPStr)] string szProduct, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szFeature, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szComponent, // LPCSTR
uint dwInstallMode, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpPathBuf, // LPSTR optional, out
IntPtr pcchPathBuf // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiProvideComponentA(
<MarshalAs(UnmanagedType.LPStr)> szProduct As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szFeature As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szComponent As String, ' LPCSTR
dwInstallMode As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> lpPathBuf As System.Text.StringBuilder, ' LPSTR optional, out
pcchPathBuf As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' szProduct : LPCSTR
' szFeature : LPCSTR
' szComponent : LPCSTR
' dwInstallMode : DWORD
' lpPathBuf : LPSTR optional, out
' pcchPathBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiProvideComponentA Lib "msi" ( _
ByVal szProduct As String, _
ByVal szFeature As String, _
ByVal szComponent As String, _
ByVal dwInstallMode As Long, _
ByVal lpPathBuf As String, _
ByVal pcchPathBuf As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiProvideComponentA = ctypes.windll.msi.MsiProvideComponentA
MsiProvideComponentA.restype = wintypes.DWORD
MsiProvideComponentA.argtypes = [
wintypes.LPCSTR, # szProduct : LPCSTR
wintypes.LPCSTR, # szFeature : LPCSTR
wintypes.LPCSTR, # szComponent : LPCSTR
wintypes.DWORD, # dwInstallMode : DWORD
wintypes.LPSTR, # lpPathBuf : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchPathBuf : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiProvideComponentA = Fiddle::Function.new(
lib['MsiProvideComponentA'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCSTR
Fiddle::TYPE_VOIDP, # szFeature : LPCSTR
Fiddle::TYPE_VOIDP, # szComponent : LPCSTR
-Fiddle::TYPE_INT, # dwInstallMode : DWORD
Fiddle::TYPE_VOIDP, # lpPathBuf : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchPathBuf : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiProvideComponentA(
szProduct: *const u8, // LPCSTR
szFeature: *const u8, // LPCSTR
szComponent: *const u8, // LPCSTR
dwInstallMode: u32, // DWORD
lpPathBuf: *mut u8, // LPSTR 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.Ansi)]
public static extern uint MsiProvideComponentA([MarshalAs(UnmanagedType.LPStr)] string szProduct, [MarshalAs(UnmanagedType.LPStr)] string szFeature, [MarshalAs(UnmanagedType.LPStr)] string szComponent, uint dwInstallMode, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpPathBuf, IntPtr pcchPathBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiProvideComponentA' -Namespace Win32 -PassThru
# $api::MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf)#uselib "msi.dll"
#func global MsiProvideComponentA "MsiProvideComponentA" sptr, sptr, sptr, sptr, sptr, sptr
; MsiProvideComponentA szProduct, szFeature, szComponent, dwInstallMode, varptr(lpPathBuf), varptr(pcchPathBuf) ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; szFeature : LPCSTR -> "sptr"
; szComponent : LPCSTR -> "sptr"
; dwInstallMode : DWORD -> "sptr"
; lpPathBuf : LPSTR optional, out -> "sptr"
; pcchPathBuf : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiProvideComponentA "MsiProvideComponentA" str, str, str, int, var, var ; res = MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf) ; szProduct : LPCSTR -> "str" ; szFeature : LPCSTR -> "str" ; szComponent : LPCSTR -> "str" ; dwInstallMode : DWORD -> "int" ; lpPathBuf : LPSTR optional, out -> "var" ; pcchPathBuf : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiProvideComponentA "MsiProvideComponentA" str, str, str, int, sptr, sptr ; res = MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, varptr(lpPathBuf), varptr(pcchPathBuf)) ; szProduct : LPCSTR -> "str" ; szFeature : LPCSTR -> "str" ; szComponent : LPCSTR -> "str" ; dwInstallMode : DWORD -> "int" ; lpPathBuf : LPSTR optional, out -> "sptr" ; pcchPathBuf : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MsiProvideComponentA(LPCSTR szProduct, LPCSTR szFeature, LPCSTR szComponent, DWORD dwInstallMode, LPSTR lpPathBuf, DWORD* pcchPathBuf) #uselib "msi.dll" #cfunc global MsiProvideComponentA "MsiProvideComponentA" str, str, str, int, var, var ; res = MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf) ; szProduct : LPCSTR -> "str" ; szFeature : LPCSTR -> "str" ; szComponent : LPCSTR -> "str" ; dwInstallMode : DWORD -> "int" ; lpPathBuf : LPSTR optional, out -> "var" ; pcchPathBuf : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiProvideComponentA(LPCSTR szProduct, LPCSTR szFeature, LPCSTR szComponent, DWORD dwInstallMode, LPSTR lpPathBuf, DWORD* pcchPathBuf) #uselib "msi.dll" #cfunc global MsiProvideComponentA "MsiProvideComponentA" str, str, str, int, intptr, intptr ; res = MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, varptr(lpPathBuf), varptr(pcchPathBuf)) ; szProduct : LPCSTR -> "str" ; szFeature : LPCSTR -> "str" ; szComponent : LPCSTR -> "str" ; dwInstallMode : DWORD -> "int" ; lpPathBuf : LPSTR optional, out -> "intptr" ; pcchPathBuf : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiProvideComponentA = msi.NewProc("MsiProvideComponentA")
)
// szProduct (LPCSTR), szFeature (LPCSTR), szComponent (LPCSTR), dwInstallMode (DWORD), lpPathBuf (LPSTR optional, out), pcchPathBuf (DWORD* optional, in/out)
r1, _, err := procMsiProvideComponentA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProduct))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szFeature))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szComponent))),
uintptr(dwInstallMode),
uintptr(lpPathBuf),
uintptr(pcchPathBuf),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiProvideComponentA(
szProduct: PAnsiChar; // LPCSTR
szFeature: PAnsiChar; // LPCSTR
szComponent: PAnsiChar; // LPCSTR
dwInstallMode: DWORD; // DWORD
lpPathBuf: PAnsiChar; // LPSTR optional, out
pcchPathBuf: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiProvideComponentA';result := DllCall("msi\MsiProvideComponentA"
, "AStr", szProduct ; LPCSTR
, "AStr", szFeature ; LPCSTR
, "AStr", szComponent ; LPCSTR
, "UInt", dwInstallMode ; DWORD
, "Ptr", lpPathBuf ; LPSTR optional, out
, "Ptr", pcchPathBuf ; DWORD* optional, in/out
, "UInt") ; return: DWORD●MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf) = DLL("msi.dll", "dword MsiProvideComponentA(char*, char*, char*, dword, char*, void*)")
# 呼び出し: MsiProvideComponentA(szProduct, szFeature, szComponent, dwInstallMode, lpPathBuf, pcchPathBuf)
# szProduct : LPCSTR -> "char*"
# szFeature : LPCSTR -> "char*"
# szComponent : LPCSTR -> "char*"
# dwInstallMode : DWORD -> "dword"
# lpPathBuf : LPSTR optional, out -> "char*"
# pcchPathBuf : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。