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

MsiReinstallFeatureA

関数
指定モードで機能を再インストールする(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiReinstallFeatureA(
    LPCSTR szProduct,
    LPCSTR szFeature,
    DWORD dwReinstallMode
);

パラメーター

名前方向説明
szProductLPCSTRin再インストールする機能を含む製品の製品コードを指定します。
szFeatureLPCSTRin再インストールする機能を指定します。指定した機能の親機能や子機能は再インストールされません。親機能または子機能を再インストールするには、それぞれについて MsiReinstallFeature 関数を個別に呼び出すか、MsiReinstallProduct 関数を使用する必要があります。
dwReinstallModeDWORDin

インストールする内容を指定します。このパラメーターには、次の値を 1 つ以上指定できます。

意味
REINSTALLMODE_FILEMISSING
ファイルが存在しない場合のみ再インストールします。
REINSTALLMODE_FILEOLDERVERSION
ファイルが存在しない、または古いバージョンである場合に再インストールします。
REINSTALLMODE_FILEEQUALVERSION
ファイルが存在しない、または同じバージョンか古いバージョンである場合に再インストールします。
REINSTALLMODE_FILEEXACT
ファイルが存在しない、または異なるバージョンである場合に再インストールします。
REINSTALLMODE_FILEVERIFY
チェックサム値を検証し、ファイルが存在しないか破損している場合に再インストールします。このフラグは、 File テーブルの Attributes 列に msidbFileAttributesChecksum を持つファイルのみを修復します。
REINSTALLMODE_FILEREPLACE
チェックサムやバージョンに関係なく、すべてのファイルを強制的に再インストールします。
REINSTALLMODE_USERDATA
Registry テーブルのうち、HKEY_CURRENT_USER

または HKEY_USERS

レジストリハイブに書き込まれる必須のレジストリエントリをすべて書き直します。
REINSTALLMODE_MACHINEDATA
Registry テーブルのうち、HKEY_LOCAL_MACHINE

または HKEY_CLASSES_ROOT

レジストリハイブに書き込まれる必須のレジストリエントリをすべて書き直します。マシン単位かユーザー単位かの割り当てに関係なく、 Class テーブルVerb テーブルPublishComponent テーブルProgID テーブルMIME テーブルIcon テーブルExtension テーブルAppID テーブルのすべての情報を書き直します。すべての 条件付きコンポーネントを再インストールします。

アプリケーションを再インストールする場合、このオプションは RegisterTypeLibraries アクションと InstallODBC アクションを実行します。

REINSTALLMODE_SHORTCUT
すべてのショートカットを再インストールし、すべてのアイコンを再キャッシュします。既存のショートカットおよびアイコンは上書きされます。
REINSTALLMODE_PACKAGE
ソースパッケージから実行し、ローカルパッケージを再キャッシュする場合に使用します。アプリケーションまたは機能の初回インストールには使用しないでください。

戻り値の型: DWORD

公式ドキュメント

機能を再インストールします。(ANSI)

戻り値

戻り値 説明
ERROR_INSTALL_FAILURE
インストールに失敗しました。
ERROR_INVALID_PARAMETER
無効なパラメーターが関数に渡されました。
ERROR_INSTALL_SERVICE_FAILURE
インストールサービスにアクセスできませんでした。
ERROR_INSTALL_SUSPEND
インストールが中断され、完了していません。
ERROR_INSTALL_USEREXIT
ユーザーがインストールをキャンセルしました。
ERROR_SUCCESS
関数は正常に完了しました。
ERROR_UNKNOWN_FEATURE
機能 ID が既知の機能を示していません。
ERROR_UNKNOWN_PRODUCT
製品コードが既知の製品を示していません。

詳細については、 表示されるエラーメッセージを参照してください。

解説(Remarks)

メモ

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

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

MsiReinstallFeatureA = ctypes.windll.msi.MsiReinstallFeatureA
MsiReinstallFeatureA.restype = wintypes.DWORD
MsiReinstallFeatureA.argtypes = [
    wintypes.LPCSTR,  # szProduct : LPCSTR
    wintypes.LPCSTR,  # szFeature : LPCSTR
    wintypes.DWORD,  # dwReinstallMode : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiReinstallFeatureA = msi.NewProc("MsiReinstallFeatureA")
)

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

extern "msi" fn MsiReinstallFeatureA(
    szProduct: [*c]const u8, // LPCSTR
    szFeature: [*c]const u8, // LPCSTR
    dwReinstallMode: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc MsiReinstallFeatureA(
    szProduct: cstring,  # LPCSTR
    szFeature: cstring,  # LPCSTR
    dwReinstallMode: uint32  # DWORD
): uint32 {.importc: "MsiReinstallFeatureA", stdcall, dynlib: "msi.dll".}
pragma(lib, "msi");
extern(Windows)
uint MsiReinstallFeatureA(
    const(char)* szProduct,   // LPCSTR
    const(char)* szFeature,   // LPCSTR
    uint dwReinstallMode   // DWORD
);
ccall((:MsiReinstallFeatureA, "msi.dll"), stdcall, UInt32,
      (Cstring, Cstring, UInt32),
      szProduct, szFeature, dwReinstallMode)
# szProduct : LPCSTR -> Cstring
# szFeature : LPCSTR -> Cstring
# dwReinstallMode : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiReinstallFeatureA(
    const char* szProduct,
    const char* szFeature,
    uint32_t dwReinstallMode);
]]
local msi = ffi.load("msi")
-- msi.MsiReinstallFeatureA(szProduct, szFeature, dwReinstallMode)
-- szProduct : LPCSTR
-- szFeature : LPCSTR
-- dwReinstallMode : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiReinstallFeatureA = lib.func('__stdcall', 'MsiReinstallFeatureA', 'uint32_t', ['str', 'str', 'uint32_t']);
// MsiReinstallFeatureA(szProduct, szFeature, dwReinstallMode)
// szProduct : LPCSTR -> 'str'
// szFeature : LPCSTR -> 'str'
// dwReinstallMode : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msi.dll", {
  MsiReinstallFeatureA: { parameters: ["buffer", "buffer", "u32"], result: "u32" },
});
// lib.symbols.MsiReinstallFeatureA(szProduct, szFeature, dwReinstallMode)
// szProduct : LPCSTR -> "buffer"
// szFeature : LPCSTR -> "buffer"
// dwReinstallMode : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiReinstallFeatureA(
    const char* szProduct,
    const char* szFeature,
    uint32_t dwReinstallMode);
C, "msi.dll");
// $ffi->MsiReinstallFeatureA(szProduct, szFeature, dwReinstallMode);
// szProduct : LPCSTR
// szFeature : LPCSTR
// dwReinstallMode : DWORD
// 構造体/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 MsiReinstallFeatureA(
        String szProduct,   // LPCSTR
        String szFeature,   // LPCSTR
        int dwReinstallMode   // DWORD
    );
}
@[Link("msi")]
lib Libmsi
  fun MsiReinstallFeatureA = MsiReinstallFeatureA(
    szProduct : UInt8*,   # LPCSTR
    szFeature : UInt8*,   # LPCSTR
    dwReinstallMode : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MsiReinstallFeatureANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Uint32);
typedef MsiReinstallFeatureADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int);
final MsiReinstallFeatureA = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiReinstallFeatureANative, MsiReinstallFeatureADart>('MsiReinstallFeatureA');
// szProduct : LPCSTR -> Pointer<Utf8>
// szFeature : LPCSTR -> Pointer<Utf8>
// dwReinstallMode : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiReinstallFeatureA(
  szProduct: PAnsiChar;   // LPCSTR
  szFeature: PAnsiChar;   // LPCSTR
  dwReinstallMode: DWORD   // DWORD
): DWORD; stdcall;
  external 'msi.dll' name 'MsiReinstallFeatureA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiReinstallFeatureA"
  c_MsiReinstallFeatureA :: CString -> CString -> Word32 -> IO Word32
-- szProduct : LPCSTR -> CString
-- szFeature : LPCSTR -> CString
-- dwReinstallMode : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msireinstallfeaturea =
  foreign "MsiReinstallFeatureA"
    (string @-> string @-> uint32_t @-> returning uint32_t)
(* szProduct : LPCSTR -> string *)
(* szFeature : LPCSTR -> string *)
(* dwReinstallMode : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)

(cffi:defcfun ("MsiReinstallFeatureA" msi-reinstall-feature-a :convention :stdcall) :uint32
  (sz-product :string)   ; LPCSTR
  (sz-feature :string)   ; LPCSTR
  (dw-reinstall-mode :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiReinstallFeatureA = Win32::API::More->new('msi',
    'DWORD MsiReinstallFeatureA(LPCSTR szProduct, LPCSTR szFeature, DWORD dwReinstallMode)');
# my $ret = $MsiReinstallFeatureA->Call($szProduct, $szFeature, $dwReinstallMode);
# szProduct : LPCSTR -> LPCSTR
# szFeature : LPCSTR -> LPCSTR
# dwReinstallMode : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い