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