MsiConfigureProductExW
関数シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiConfigureProductExW(
LPCWSTR szProduct,
INSTALLLEVEL iInstallLevel,
INSTALLSTATE eInstallState,
LPCWSTR szCommandLine // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| szProduct | LPCWSTR | in | 構成する製品の製品コードを指定します。 | ||||||||||||
| iInstallLevel | INSTALLLEVEL | in | 製品を既定の状態にインストールする際に、どこまでをインストールするかを指定します。eInstallState パラメーターが INSTALLSTATE_DEFAULT 以外の値に設定されている場合、iInstallLevel パラメーターは無視され、すべての機能がインストールされます。 このパラメーターには次のいずれかの値を指定できます。
| ||||||||||||
| eInstallState | INSTALLSTATE | in | 製品のインストール状態を指定します。このパラメーターには次のいずれかの値を指定できます。
| ||||||||||||
| szCommandLine | LPCWSTR | inoptional | コマンドラインのプロパティ設定を指定します。これは Property=Setting Property=Setting の形式のリストである必要があります。詳細については、 About Properties を参照してください。 |
戻り値の型: DWORD
公式ドキュメント
製品をインストールまたはアンインストールします。(MsiConfigureProductExW)
戻り値
| 値 | 意味 |
|---|---|
| 無効なパラメーターが関数に渡されました。 | |
| 関数が成功しました。 | |
|
詳細については、 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 (Unicode / -W)
#include <windows.h>
DWORD MsiConfigureProductExW(
LPCWSTR szProduct,
INSTALLLEVEL iInstallLevel,
INSTALLSTATE eInstallState,
LPCWSTR szCommandLine // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiConfigureProductExW(
[MarshalAs(UnmanagedType.LPWStr)] string szProduct, // LPCWSTR
int iInstallLevel, // INSTALLLEVEL
int eInstallState, // INSTALLSTATE
[MarshalAs(UnmanagedType.LPWStr)] string szCommandLine // LPCWSTR optional
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiConfigureProductExW(
<MarshalAs(UnmanagedType.LPWStr)> szProduct As String, ' LPCWSTR
iInstallLevel As Integer, ' INSTALLLEVEL
eInstallState As Integer, ' INSTALLSTATE
<MarshalAs(UnmanagedType.LPWStr)> szCommandLine As String ' LPCWSTR optional
) As UInteger
End Function' szProduct : LPCWSTR
' iInstallLevel : INSTALLLEVEL
' eInstallState : INSTALLSTATE
' szCommandLine : LPCWSTR optional
Declare PtrSafe Function MsiConfigureProductExW Lib "msi" ( _
ByVal szProduct As LongPtr, _
ByVal iInstallLevel As Long, _
ByVal eInstallState As Long, _
ByVal szCommandLine As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiConfigureProductExW = ctypes.windll.msi.MsiConfigureProductExW
MsiConfigureProductExW.restype = wintypes.DWORD
MsiConfigureProductExW.argtypes = [
wintypes.LPCWSTR, # szProduct : LPCWSTR
ctypes.c_int, # iInstallLevel : INSTALLLEVEL
ctypes.c_int, # eInstallState : INSTALLSTATE
wintypes.LPCWSTR, # szCommandLine : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiConfigureProductExW = Fiddle::Function.new(
lib['MsiConfigureProductExW'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCWSTR
Fiddle::TYPE_INT, # iInstallLevel : INSTALLLEVEL
Fiddle::TYPE_INT, # eInstallState : INSTALLSTATE
Fiddle::TYPE_VOIDP, # szCommandLine : LPCWSTR optional
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiConfigureProductExW(
szProduct: *const u16, // LPCWSTR
iInstallLevel: i32, // INSTALLLEVEL
eInstallState: i32, // INSTALLSTATE
szCommandLine: *const u16 // LPCWSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiConfigureProductExW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, int iInstallLevel, int eInstallState, [MarshalAs(UnmanagedType.LPWStr)] string szCommandLine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiConfigureProductExW' -Namespace Win32 -PassThru
# $api::MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)#uselib "msi.dll"
#func global MsiConfigureProductExW "MsiConfigureProductExW" wptr, wptr, wptr, wptr
; MsiConfigureProductExW szProduct, iInstallLevel, eInstallState, szCommandLine ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; iInstallLevel : INSTALLLEVEL -> "wptr"
; eInstallState : INSTALLSTATE -> "wptr"
; szCommandLine : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiConfigureProductExW "MsiConfigureProductExW" wstr, int, int, wstr
; res = MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)
; szProduct : LPCWSTR -> "wstr"
; iInstallLevel : INSTALLLEVEL -> "int"
; eInstallState : INSTALLSTATE -> "int"
; szCommandLine : LPCWSTR optional -> "wstr"; DWORD MsiConfigureProductExW(LPCWSTR szProduct, INSTALLLEVEL iInstallLevel, INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
#uselib "msi.dll"
#cfunc global MsiConfigureProductExW "MsiConfigureProductExW" wstr, int, int, wstr
; res = MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)
; szProduct : LPCWSTR -> "wstr"
; iInstallLevel : INSTALLLEVEL -> "int"
; eInstallState : INSTALLSTATE -> "int"
; szCommandLine : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiConfigureProductExW = msi.NewProc("MsiConfigureProductExW")
)
// szProduct (LPCWSTR), iInstallLevel (INSTALLLEVEL), eInstallState (INSTALLSTATE), szCommandLine (LPCWSTR optional)
r1, _, err := procMsiConfigureProductExW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
uintptr(iInstallLevel),
uintptr(eInstallState),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szCommandLine))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiConfigureProductExW(
szProduct: PWideChar; // LPCWSTR
iInstallLevel: Integer; // INSTALLLEVEL
eInstallState: Integer; // INSTALLSTATE
szCommandLine: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiConfigureProductExW';result := DllCall("msi\MsiConfigureProductExW"
, "WStr", szProduct ; LPCWSTR
, "Int", iInstallLevel ; INSTALLLEVEL
, "Int", eInstallState ; INSTALLSTATE
, "WStr", szCommandLine ; LPCWSTR optional
, "UInt") ; return: DWORD●MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine) = DLL("msi.dll", "dword MsiConfigureProductExW(char*, int, int, char*)")
# 呼び出し: MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)
# szProduct : LPCWSTR -> "char*"
# iInstallLevel : INSTALLLEVEL -> "int"
# eInstallState : INSTALLSTATE -> "int"
# szCommandLine : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "msi" fn MsiConfigureProductExW(
szProduct: [*c]const u16, // LPCWSTR
iInstallLevel: i32, // INSTALLLEVEL
eInstallState: i32, // INSTALLSTATE
szCommandLine: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc MsiConfigureProductExW(
szProduct: WideCString, # LPCWSTR
iInstallLevel: int32, # INSTALLLEVEL
eInstallState: int32, # INSTALLSTATE
szCommandLine: WideCString # LPCWSTR optional
): uint32 {.importc: "MsiConfigureProductExW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "msi");
extern(Windows)
uint MsiConfigureProductExW(
const(wchar)* szProduct, // LPCWSTR
int iInstallLevel, // INSTALLLEVEL
int eInstallState, // INSTALLSTATE
const(wchar)* szCommandLine // LPCWSTR optional
);ccall((:MsiConfigureProductExW, "msi.dll"), stdcall, UInt32,
(Cwstring, Int32, Int32, Cwstring),
szProduct, iInstallLevel, eInstallState, szCommandLine)
# szProduct : LPCWSTR -> Cwstring
# iInstallLevel : INSTALLLEVEL -> Int32
# eInstallState : INSTALLSTATE -> Int32
# szCommandLine : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiConfigureProductExW(
const uint16_t* szProduct,
int32_t iInstallLevel,
int32_t eInstallState,
const uint16_t* szCommandLine);
]]
local msi = ffi.load("msi")
-- msi.MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)
-- szProduct : LPCWSTR
-- iInstallLevel : INSTALLLEVEL
-- eInstallState : INSTALLSTATE
-- szCommandLine : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiConfigureProductExW = lib.func('__stdcall', 'MsiConfigureProductExW', 'uint32_t', ['str16', 'int32_t', 'int32_t', 'str16']);
// MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)
// szProduct : LPCWSTR -> 'str16'
// iInstallLevel : INSTALLLEVEL -> 'int32_t'
// eInstallState : INSTALLSTATE -> 'int32_t'
// szCommandLine : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiConfigureProductExW: { parameters: ["buffer", "i32", "i32", "buffer"], result: "u32" },
});
// lib.symbols.MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine)
// szProduct : LPCWSTR -> "buffer"
// iInstallLevel : INSTALLLEVEL -> "i32"
// eInstallState : INSTALLSTATE -> "i32"
// szCommandLine : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiConfigureProductExW(
const uint16_t* szProduct,
int32_t iInstallLevel,
int32_t eInstallState,
const uint16_t* szCommandLine);
C, "msi.dll");
// $ffi->MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, szCommandLine);
// szProduct : LPCWSTR
// iInstallLevel : INSTALLLEVEL
// eInstallState : INSTALLSTATE
// szCommandLine : LPCWSTR 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.UNICODE_OPTIONS);
int MsiConfigureProductExW(
WString szProduct, // LPCWSTR
int iInstallLevel, // INSTALLLEVEL
int eInstallState, // INSTALLSTATE
WString szCommandLine // LPCWSTR optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("msi")]
lib Libmsi
fun MsiConfigureProductExW = MsiConfigureProductExW(
szProduct : UInt16*, # LPCWSTR
iInstallLevel : Int32, # INSTALLLEVEL
eInstallState : Int32, # INSTALLSTATE
szCommandLine : UInt16* # LPCWSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiConfigureProductExWNative = Uint32 Function(Pointer<Utf16>, Int32, Int32, Pointer<Utf16>);
typedef MsiConfigureProductExWDart = int Function(Pointer<Utf16>, int, int, Pointer<Utf16>);
final MsiConfigureProductExW = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiConfigureProductExWNative, MsiConfigureProductExWDart>('MsiConfigureProductExW');
// szProduct : LPCWSTR -> Pointer<Utf16>
// iInstallLevel : INSTALLLEVEL -> Int32
// eInstallState : INSTALLSTATE -> Int32
// szCommandLine : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiConfigureProductExW(
szProduct: PWideChar; // LPCWSTR
iInstallLevel: Integer; // INSTALLLEVEL
eInstallState: Integer; // INSTALLSTATE
szCommandLine: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiConfigureProductExW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiConfigureProductExW"
c_MsiConfigureProductExW :: CWString -> Int32 -> Int32 -> CWString -> IO Word32
-- szProduct : LPCWSTR -> CWString
-- iInstallLevel : INSTALLLEVEL -> Int32
-- eInstallState : INSTALLSTATE -> Int32
-- szCommandLine : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msiconfigureproductexw =
foreign "MsiConfigureProductExW"
((ptr uint16_t) @-> int32_t @-> int32_t @-> (ptr uint16_t) @-> returning uint32_t)
(* szProduct : LPCWSTR -> (ptr uint16_t) *)
(* iInstallLevel : INSTALLLEVEL -> int32_t *)
(* eInstallState : INSTALLSTATE -> int32_t *)
(* szCommandLine : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiConfigureProductExW" msi-configure-product-ex-w :convention :stdcall) :uint32
(sz-product (:string :encoding :utf-16le)) ; LPCWSTR
(i-install-level :int32) ; INSTALLLEVEL
(e-install-state :int32) ; INSTALLSTATE
(sz-command-line (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiConfigureProductExW = Win32::API::More->new('msi',
'DWORD MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel, int eInstallState, LPCWSTR szCommandLine)');
# my $ret = $MsiConfigureProductExW->Call($szProduct, $iInstallLevel, $eInstallState, $szCommandLine);
# szProduct : LPCWSTR -> LPCWSTR
# iInstallLevel : INSTALLLEVEL -> int
# eInstallState : INSTALLSTATE -> int
# szCommandLine : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f MsiConfigureProductExA (ANSI版) — コマンドライン指定で製品の構成を変更する(ANSI版)。
- f MsiConfigureProductW — 製品のインストール状態を構成変更する(Unicode版)。