ホーム › System.ApplicationInstallationAndServicing › MsiInstallMissingComponentA
MsiInstallMissingComponentA
関数製品の不足コンポーネントを指定した状態でインストールする。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiInstallMissingComponentA(
LPCSTR szProduct,
LPCSTR szComponent,
INSTALLSTATE eInstallState
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| szProduct | LPCSTR | in | インストールするコンポーネントを所有する製品の製品コードを指定します。 | ||||||||
| szComponent | LPCSTR | in | インストールするコンポーネントを識別します。 | ||||||||
| eInstallState | INSTALLSTATE | in | コンポーネントをインストールする方法を指定します。このパラメーターは次のいずれかの値である必要があります。
|
戻り値の型: DWORD
公式ドキュメント
MsiInstallMissingComponent 関数は、予期せず欠落しているファイルをインストールします。(ANSI)
戻り値
| 値 | 意味 |
|---|---|
| 構成情報が破損しています。 | |
| インストールに失敗しました。 | |
| ソースが利用できませんでした。 | |
| インストールが中断されました。 | |
| ユーザーがインストールを終了しました。 | |
| パラメーターのいずれかが無効です。 | |
| 関数は正常に完了しました。 | |
| 製品コードが認識されません。 |
エラーメッセージの詳細については、 Displayed Error Messages を参照してください。
解説(Remarks)
MsiInstallMissingComponent 関数は、コンポーネントが属する機能を解決します。その後、必要な追加ディスク領域が最も少ない製品機能がインストールされます。
メモ
msi.h ヘッダーは、MsiInstallMissingComponent を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスの使用を、エンコーディング非依存でないコードと混在させると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 // DWORDfunction 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)。const std = @import("std");
extern "msi" fn MsiInstallMissingComponentA(
szProduct: [*c]const u8, // LPCSTR
szComponent: [*c]const u8, // LPCSTR
eInstallState: i32 // INSTALLSTATE
) callconv(std.os.windows.WINAPI) u32;proc MsiInstallMissingComponentA(
szProduct: cstring, # LPCSTR
szComponent: cstring, # LPCSTR
eInstallState: int32 # INSTALLSTATE
): uint32 {.importc: "MsiInstallMissingComponentA", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiInstallMissingComponentA(
const(char)* szProduct, // LPCSTR
const(char)* szComponent, // LPCSTR
int eInstallState // INSTALLSTATE
);ccall((:MsiInstallMissingComponentA, "msi.dll"), stdcall, UInt32,
(Cstring, Cstring, Int32),
szProduct, szComponent, eInstallState)
# szProduct : LPCSTR -> Cstring
# szComponent : LPCSTR -> Cstring
# eInstallState : INSTALLSTATE -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiInstallMissingComponentA(
const char* szProduct,
const char* szComponent,
int32_t eInstallState);
]]
local msi = ffi.load("msi")
-- msi.MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
-- szProduct : LPCSTR
-- szComponent : LPCSTR
-- eInstallState : INSTALLSTATE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiInstallMissingComponentA = lib.func('__stdcall', 'MsiInstallMissingComponentA', 'uint32_t', ['str', 'str', 'int32_t']);
// MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
// szProduct : LPCSTR -> 'str'
// szComponent : LPCSTR -> 'str'
// eInstallState : INSTALLSTATE -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiInstallMissingComponentA: { parameters: ["buffer", "buffer", "i32"], result: "u32" },
});
// lib.symbols.MsiInstallMissingComponentA(szProduct, szComponent, eInstallState)
// szProduct : LPCSTR -> "buffer"
// szComponent : LPCSTR -> "buffer"
// eInstallState : INSTALLSTATE -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiInstallMissingComponentA(
const char* szProduct,
const char* szComponent,
int32_t eInstallState);
C, "msi.dll");
// $ffi->MsiInstallMissingComponentA(szProduct, szComponent, eInstallState);
// szProduct : LPCSTR
// szComponent : LPCSTR
// eInstallState : INSTALLSTATE
// 構造体/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.ASCII_OPTIONS);
int MsiInstallMissingComponentA(
String szProduct, // LPCSTR
String szComponent, // LPCSTR
int eInstallState // INSTALLSTATE
);
}@[Link("msi")]
lib Libmsi
fun MsiInstallMissingComponentA = MsiInstallMissingComponentA(
szProduct : UInt8*, # LPCSTR
szComponent : UInt8*, # LPCSTR
eInstallState : Int32 # INSTALLSTATE
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiInstallMissingComponentANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Int32);
typedef MsiInstallMissingComponentADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int);
final MsiInstallMissingComponentA = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiInstallMissingComponentANative, MsiInstallMissingComponentADart>('MsiInstallMissingComponentA');
// szProduct : LPCSTR -> Pointer<Utf8>
// szComponent : LPCSTR -> Pointer<Utf8>
// eInstallState : INSTALLSTATE -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiInstallMissingComponentA(
szProduct: PAnsiChar; // LPCSTR
szComponent: PAnsiChar; // LPCSTR
eInstallState: Integer // INSTALLSTATE
): DWORD; stdcall;
external 'msi.dll' name 'MsiInstallMissingComponentA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiInstallMissingComponentA"
c_MsiInstallMissingComponentA :: CString -> CString -> Int32 -> IO Word32
-- szProduct : LPCSTR -> CString
-- szComponent : LPCSTR -> CString
-- eInstallState : INSTALLSTATE -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msiinstallmissingcomponenta =
foreign "MsiInstallMissingComponentA"
(string @-> string @-> int32_t @-> returning uint32_t)
(* szProduct : LPCSTR -> string *)
(* szComponent : LPCSTR -> string *)
(* eInstallState : INSTALLSTATE -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiInstallMissingComponentA" msi-install-missing-component-a :convention :stdcall) :uint32
(sz-product :string) ; LPCSTR
(sz-component :string) ; LPCSTR
(e-install-state :int32)) ; INSTALLSTATE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiInstallMissingComponentA = Win32::API::More->new('msi',
'DWORD MsiInstallMissingComponentA(LPCSTR szProduct, LPCSTR szComponent, int eInstallState)');
# my $ret = $MsiInstallMissingComponentA->Call($szProduct, $szComponent, $eInstallState);
# szProduct : LPCSTR -> LPCSTR
# szComponent : LPCSTR -> LPCSTR
# eInstallState : INSTALLSTATE -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f MsiInstallMissingComponentW (Unicode版) — 製品の不足コンポーネントを指定した状態でインストールする。
使用する型