MsiConfigureProductExA
関数シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiConfigureProductExA(
LPCSTR szProduct,
INSTALLLEVEL iInstallLevel,
INSTALLSTATE eInstallState,
LPCSTR szCommandLine // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| szProduct | LPCSTR | in | 構成する製品の製品コードを指定します。 | ||||||||||||
| iInstallLevel | INSTALLLEVEL | in | 製品を既定の状態でインストールする際に、どこまでをインストールするかを指定します。eInstallState パラメーターに INSTALLSTATE_DEFAULT 以外の値を設定した場合、iInstallLevel パラメーターは無視され、すべての機能がインストールされます。 このパラメーターには次のいずれかの値を指定できます。
| ||||||||||||
| eInstallState | INSTALLSTATE | in | 製品のインストール状態を指定します。このパラメーターには次のいずれかの値を指定できます。
| ||||||||||||
| szCommandLine | LPCSTR | inoptional | コマンドラインのプロパティ設定を指定します。これは Property=Setting Property=Setting 形式のリストである必要があります。詳細については、 About Properties を参照してください。 |
戻り値の型: DWORD
公式ドキュメント
製品をインストールまたはアンインストールします。(MsiConfigureProductExA)
戻り値
| 値 | 意味 |
|---|---|
| 無効なパラメーターが関数に渡されました。 | |
| 関数は成功しました。 | |
|
詳細については、 Error Codes を参照してください。 |
| 初期化に関連するエラーが発生しました。 |
解説(Remarks)
szCommandLine として渡すコマンドラインには、 Feature Installation Options Properties のいずれかを含めることができます。この場合、渡される eInstallState は INSTALLSTATE_DEFAULT である必要があります。
eInstallState パラメーターに INSTALLSTATE_DEFAULT 以外の値を設定した場合、iInstallLevel パラメーターは無視され、製品のすべての機能がインストールされます。eInstallState パラメーターが INSTALLSTATE_DEFAULT に設定されていない場合に個々の機能のインストールを制御するには、 MsiConfigureFeature を使用してください。
MsiConfigureProductEx 関数は、現在の設定を使用してユーザーインターフェイスを表示します。ユーザーインターフェイスの設定は、 MsiSetInternalUI、MsiSetExternalUI、または MsiSetExternalUIRecord で変更できます。
msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiConfigureProductEx を定義します。エンコーディング中立のエイリアスを、エンコーディング中立でないコードと混在して使用すると、不一致が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiConfigureProductExA(
LPCSTR szProduct,
INSTALLLEVEL iInstallLevel,
INSTALLSTATE eInstallState,
LPCSTR szCommandLine // optional
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiConfigureProductExA(
[MarshalAs(UnmanagedType.LPStr)] string szProduct, // LPCSTR
int iInstallLevel, // INSTALLLEVEL
int eInstallState, // INSTALLSTATE
[MarshalAs(UnmanagedType.LPStr)] string szCommandLine // LPCSTR optional
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiConfigureProductExA(
<MarshalAs(UnmanagedType.LPStr)> szProduct As String, ' LPCSTR
iInstallLevel As Integer, ' INSTALLLEVEL
eInstallState As Integer, ' INSTALLSTATE
<MarshalAs(UnmanagedType.LPStr)> szCommandLine As String ' LPCSTR optional
) As UInteger
End Function' szProduct : LPCSTR
' iInstallLevel : INSTALLLEVEL
' eInstallState : INSTALLSTATE
' szCommandLine : LPCSTR optional
Declare PtrSafe Function MsiConfigureProductExA Lib "msi" ( _
ByVal szProduct As String, _
ByVal iInstallLevel As Long, _
ByVal eInstallState As Long, _
ByVal szCommandLine As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiConfigureProductExA = ctypes.windll.msi.MsiConfigureProductExA
MsiConfigureProductExA.restype = wintypes.DWORD
MsiConfigureProductExA.argtypes = [
wintypes.LPCSTR, # szProduct : LPCSTR
ctypes.c_int, # iInstallLevel : INSTALLLEVEL
ctypes.c_int, # eInstallState : INSTALLSTATE
wintypes.LPCSTR, # szCommandLine : LPCSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiConfigureProductExA = Fiddle::Function.new(
lib['MsiConfigureProductExA'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCSTR
Fiddle::TYPE_INT, # iInstallLevel : INSTALLLEVEL
Fiddle::TYPE_INT, # eInstallState : INSTALLSTATE
Fiddle::TYPE_VOIDP, # szCommandLine : LPCSTR optional
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiConfigureProductExA(
szProduct: *const u8, // LPCSTR
iInstallLevel: i32, // INSTALLLEVEL
eInstallState: i32, // INSTALLSTATE
szCommandLine: *const u8 // LPCSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiConfigureProductExA([MarshalAs(UnmanagedType.LPStr)] string szProduct, int iInstallLevel, int eInstallState, [MarshalAs(UnmanagedType.LPStr)] string szCommandLine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiConfigureProductExA' -Namespace Win32 -PassThru
# $api::MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)#uselib "msi.dll"
#func global MsiConfigureProductExA "MsiConfigureProductExA" sptr, sptr, sptr, sptr
; MsiConfigureProductExA szProduct, iInstallLevel, eInstallState, szCommandLine ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; iInstallLevel : INSTALLLEVEL -> "sptr"
; eInstallState : INSTALLSTATE -> "sptr"
; szCommandLine : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiConfigureProductExA "MsiConfigureProductExA" str, int, int, str
; res = MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)
; szProduct : LPCSTR -> "str"
; iInstallLevel : INSTALLLEVEL -> "int"
; eInstallState : INSTALLSTATE -> "int"
; szCommandLine : LPCSTR optional -> "str"; DWORD MsiConfigureProductExA(LPCSTR szProduct, INSTALLLEVEL iInstallLevel, INSTALLSTATE eInstallState, LPCSTR szCommandLine)
#uselib "msi.dll"
#cfunc global MsiConfigureProductExA "MsiConfigureProductExA" str, int, int, str
; res = MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)
; szProduct : LPCSTR -> "str"
; iInstallLevel : INSTALLLEVEL -> "int"
; eInstallState : INSTALLSTATE -> "int"
; szCommandLine : LPCSTR optional -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiConfigureProductExA = msi.NewProc("MsiConfigureProductExA")
)
// szProduct (LPCSTR), iInstallLevel (INSTALLLEVEL), eInstallState (INSTALLSTATE), szCommandLine (LPCSTR optional)
r1, _, err := procMsiConfigureProductExA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProduct))),
uintptr(iInstallLevel),
uintptr(eInstallState),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szCommandLine))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiConfigureProductExA(
szProduct: PAnsiChar; // LPCSTR
iInstallLevel: Integer; // INSTALLLEVEL
eInstallState: Integer; // INSTALLSTATE
szCommandLine: PAnsiChar // LPCSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiConfigureProductExA';result := DllCall("msi\MsiConfigureProductExA"
, "AStr", szProduct ; LPCSTR
, "Int", iInstallLevel ; INSTALLLEVEL
, "Int", eInstallState ; INSTALLSTATE
, "AStr", szCommandLine ; LPCSTR optional
, "UInt") ; return: DWORD●MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine) = DLL("msi.dll", "dword MsiConfigureProductExA(char*, int, int, char*)")
# 呼び出し: MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)
# szProduct : LPCSTR -> "char*"
# iInstallLevel : INSTALLLEVEL -> "int"
# eInstallState : INSTALLSTATE -> "int"
# szCommandLine : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiConfigureProductExA(
szProduct: [*c]const u8, // LPCSTR
iInstallLevel: i32, // INSTALLLEVEL
eInstallState: i32, // INSTALLSTATE
szCommandLine: [*c]const u8 // LPCSTR optional
) callconv(std.os.windows.WINAPI) u32;proc MsiConfigureProductExA(
szProduct: cstring, # LPCSTR
iInstallLevel: int32, # INSTALLLEVEL
eInstallState: int32, # INSTALLSTATE
szCommandLine: cstring # LPCSTR optional
): uint32 {.importc: "MsiConfigureProductExA", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiConfigureProductExA(
const(char)* szProduct, // LPCSTR
int iInstallLevel, // INSTALLLEVEL
int eInstallState, // INSTALLSTATE
const(char)* szCommandLine // LPCSTR optional
);ccall((:MsiConfigureProductExA, "msi.dll"), stdcall, UInt32,
(Cstring, Int32, Int32, Cstring),
szProduct, iInstallLevel, eInstallState, szCommandLine)
# szProduct : LPCSTR -> Cstring
# iInstallLevel : INSTALLLEVEL -> Int32
# eInstallState : INSTALLSTATE -> Int32
# szCommandLine : LPCSTR optional -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiConfigureProductExA(
const char* szProduct,
int32_t iInstallLevel,
int32_t eInstallState,
const char* szCommandLine);
]]
local msi = ffi.load("msi")
-- msi.MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)
-- szProduct : LPCSTR
-- iInstallLevel : INSTALLLEVEL
-- eInstallState : INSTALLSTATE
-- szCommandLine : LPCSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiConfigureProductExA = lib.func('__stdcall', 'MsiConfigureProductExA', 'uint32_t', ['str', 'int32_t', 'int32_t', 'str']);
// MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)
// szProduct : LPCSTR -> 'str'
// iInstallLevel : INSTALLLEVEL -> 'int32_t'
// eInstallState : INSTALLSTATE -> 'int32_t'
// szCommandLine : LPCSTR optional -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiConfigureProductExA: { parameters: ["buffer", "i32", "i32", "buffer"], result: "u32" },
});
// lib.symbols.MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine)
// szProduct : LPCSTR -> "buffer"
// iInstallLevel : INSTALLLEVEL -> "i32"
// eInstallState : INSTALLSTATE -> "i32"
// szCommandLine : LPCSTR optional -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiConfigureProductExA(
const char* szProduct,
int32_t iInstallLevel,
int32_t eInstallState,
const char* szCommandLine);
C, "msi.dll");
// $ffi->MsiConfigureProductExA(szProduct, iInstallLevel, eInstallState, szCommandLine);
// szProduct : LPCSTR
// iInstallLevel : INSTALLLEVEL
// eInstallState : INSTALLSTATE
// szCommandLine : LPCSTR optional
// 構造体/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 MsiConfigureProductExA(
String szProduct, // LPCSTR
int iInstallLevel, // INSTALLLEVEL
int eInstallState, // INSTALLSTATE
String szCommandLine // LPCSTR optional
);
}@[Link("msi")]
lib Libmsi
fun MsiConfigureProductExA = MsiConfigureProductExA(
szProduct : UInt8*, # LPCSTR
iInstallLevel : Int32, # INSTALLLEVEL
eInstallState : Int32, # INSTALLSTATE
szCommandLine : UInt8* # LPCSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiConfigureProductExANative = Uint32 Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>);
typedef MsiConfigureProductExADart = int Function(Pointer<Utf8>, int, int, Pointer<Utf8>);
final MsiConfigureProductExA = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiConfigureProductExANative, MsiConfigureProductExADart>('MsiConfigureProductExA');
// szProduct : LPCSTR -> Pointer<Utf8>
// iInstallLevel : INSTALLLEVEL -> Int32
// eInstallState : INSTALLSTATE -> Int32
// szCommandLine : LPCSTR optional -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiConfigureProductExA(
szProduct: PAnsiChar; // LPCSTR
iInstallLevel: Integer; // INSTALLLEVEL
eInstallState: Integer; // INSTALLSTATE
szCommandLine: PAnsiChar // LPCSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiConfigureProductExA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiConfigureProductExA"
c_MsiConfigureProductExA :: CString -> Int32 -> Int32 -> CString -> IO Word32
-- szProduct : LPCSTR -> CString
-- iInstallLevel : INSTALLLEVEL -> Int32
-- eInstallState : INSTALLSTATE -> Int32
-- szCommandLine : LPCSTR optional -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msiconfigureproductexa =
foreign "MsiConfigureProductExA"
(string @-> int32_t @-> int32_t @-> string @-> returning uint32_t)
(* szProduct : LPCSTR -> string *)
(* iInstallLevel : INSTALLLEVEL -> int32_t *)
(* eInstallState : INSTALLSTATE -> int32_t *)
(* szCommandLine : LPCSTR optional -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiConfigureProductExA" msi-configure-product-ex-a :convention :stdcall) :uint32
(sz-product :string) ; LPCSTR
(i-install-level :int32) ; INSTALLLEVEL
(e-install-state :int32) ; INSTALLSTATE
(sz-command-line :string)) ; LPCSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiConfigureProductExA = Win32::API::More->new('msi',
'DWORD MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel, int eInstallState, LPCSTR szCommandLine)');
# my $ret = $MsiConfigureProductExA->Call($szProduct, $iInstallLevel, $eInstallState, $szCommandLine);
# szProduct : LPCSTR -> LPCSTR
# iInstallLevel : INSTALLLEVEL -> int
# eInstallState : INSTALLSTATE -> int
# szCommandLine : LPCSTR optional -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f MsiConfigureProductExW (Unicode版) — コマンドライン指定で製品の構成を変更する(Unicode版)。
- f MsiConfigureProductA — 製品のインストール状態を構成変更する(ANSI版)。