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

MsiInstallMissingComponentA

関数
製品の不足コンポーネントを指定した状態でインストールする。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiInstallMissingComponentA(
    LPCSTR szProduct,
    LPCSTR szComponent,
    INSTALLSTATE eInstallState
);

パラメーター

名前方向
szProductLPCSTRin
szComponentLPCSTRin
eInstallStateINSTALLSTATEin

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiInstallMissingComponentA(
    LPCSTR szProduct,
    LPCSTR szComponent,
    INSTALLSTATE eInstallState
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiInstallMissingComponentA(
    [MarshalAs(UnmanagedType.LPStr)] string szProduct,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szComponent,   // LPCSTR
    int eInstallState   // INSTALLSTATE
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiInstallMissingComponentA(
    <MarshalAs(UnmanagedType.LPStr)> szProduct As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szComponent As String,   ' LPCSTR
    eInstallState As Integer   ' INSTALLSTATE
) As UInteger
End Function
' szProduct : LPCSTR
' szComponent : LPCSTR
' eInstallState : INSTALLSTATE
Declare PtrSafe Function MsiInstallMissingComponentA Lib "msi" ( _
    ByVal szProduct As String, _
    ByVal szComponent As String, _
    ByVal eInstallState As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiInstallMissingComponentA = ctypes.windll.msi.MsiInstallMissingComponentA
MsiInstallMissingComponentA.restype = wintypes.DWORD
MsiInstallMissingComponentA.argtypes = [
    wintypes.LPCSTR,  # szProduct : LPCSTR
    wintypes.LPCSTR,  # szComponent : LPCSTR
    ctypes.c_int,  # eInstallState : INSTALLSTATE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiInstallMissingComponentA = Fiddle::Function.new(
  lib['MsiInstallMissingComponentA'],
  [
    Fiddle::TYPE_VOIDP,  # szProduct : LPCSTR
    Fiddle::TYPE_VOIDP,  # szComponent : LPCSTR
    Fiddle::TYPE_INT,  # eInstallState : INSTALLSTATE
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiInstallMissingComponentA(
        szProduct: *const u8,  // LPCSTR
        szComponent: *const u8,  // LPCSTR
        eInstallState: i32  // INSTALLSTATE
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiInstallMissingComponentA([MarshalAs(UnmanagedType.LPStr)] string szProduct, [MarshalAs(UnmanagedType.LPStr)] string szComponent, int eInstallState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiInstallMissingComponentA' -Namespace Win32 -PassThru
# $api::MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
#uselib "msi.dll"
#func global MsiInstallMissingComponentA "MsiInstallMissingComponentA" sptr, sptr, sptr
; MsiInstallMissingComponentA szProduct, szComponent, eInstallState   ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; szComponent : LPCSTR -> "sptr"
; eInstallState : INSTALLSTATE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiInstallMissingComponentA "MsiInstallMissingComponentA" str, str, int
; res = MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
; szProduct : LPCSTR -> "str"
; szComponent : LPCSTR -> "str"
; eInstallState : INSTALLSTATE -> "int"
; DWORD MsiInstallMissingComponentA(LPCSTR szProduct, LPCSTR szComponent, INSTALLSTATE eInstallState)
#uselib "msi.dll"
#cfunc global MsiInstallMissingComponentA "MsiInstallMissingComponentA" str, str, int
; res = MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
; szProduct : LPCSTR -> "str"
; szComponent : LPCSTR -> "str"
; eInstallState : INSTALLSTATE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiInstallMissingComponentA = msi.NewProc("MsiInstallMissingComponentA")
)

// szProduct (LPCSTR), szComponent (LPCSTR), eInstallState (INSTALLSTATE)
r1, _, err := procMsiInstallMissingComponentA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szProduct))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szComponent))),
	uintptr(eInstallState),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiInstallMissingComponentA(
  szProduct: PAnsiChar;   // LPCSTR
  szComponent: PAnsiChar;   // LPCSTR
  eInstallState: Integer   // INSTALLSTATE
): DWORD; stdcall;
  external 'msi.dll' name 'MsiInstallMissingComponentA';
result := DllCall("msi\MsiInstallMissingComponentA"
    , "AStr", szProduct   ; LPCSTR
    , "AStr", szComponent   ; LPCSTR
    , "Int", eInstallState   ; INSTALLSTATE
    , "UInt")   ; return: DWORD
●MsiInstallMissingComponentA(szProduct, szComponent, eInstallState) = DLL("msi.dll", "dword MsiInstallMissingComponentA(char*, char*, int)")
# 呼び出し: MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
# szProduct : LPCSTR -> "char*"
# szComponent : LPCSTR -> "char*"
# eInstallState : INSTALLSTATE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。