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

MsiConfigureProductW

関数
製品のインストール状態を構成変更する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiConfigureProductW(
    LPCWSTR szProduct,
    INSTALLLEVEL iInstallLevel,
    INSTALLSTATE eInstallState
);

パラメーター

名前方向
szProductLPCWSTRin
iInstallLevelINSTALLLEVELin
eInstallStateINSTALLSTATEin

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiConfigureProductW(
    LPCWSTR szProduct,
    INSTALLLEVEL iInstallLevel,
    INSTALLSTATE eInstallState
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiConfigureProductW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProduct,   // LPCWSTR
    int iInstallLevel,   // INSTALLLEVEL
    int eInstallState   // INSTALLSTATE
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiConfigureProductW(
    <MarshalAs(UnmanagedType.LPWStr)> szProduct As String,   ' LPCWSTR
    iInstallLevel As Integer,   ' INSTALLLEVEL
    eInstallState As Integer   ' INSTALLSTATE
) As UInteger
End Function
' szProduct : LPCWSTR
' iInstallLevel : INSTALLLEVEL
' eInstallState : INSTALLSTATE
Declare PtrSafe Function MsiConfigureProductW Lib "msi" ( _
    ByVal szProduct As LongPtr, _
    ByVal iInstallLevel As Long, _
    ByVal eInstallState As Long) 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

MsiConfigureProductW = ctypes.windll.msi.MsiConfigureProductW
MsiConfigureProductW.restype = wintypes.DWORD
MsiConfigureProductW.argtypes = [
    wintypes.LPCWSTR,  # szProduct : LPCWSTR
    ctypes.c_int,  # iInstallLevel : INSTALLLEVEL
    ctypes.c_int,  # eInstallState : INSTALLSTATE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiConfigureProductW = Fiddle::Function.new(
  lib['MsiConfigureProductW'],
  [
    Fiddle::TYPE_VOIDP,  # szProduct : LPCWSTR
    Fiddle::TYPE_INT,  # iInstallLevel : INSTALLLEVEL
    Fiddle::TYPE_INT,  # eInstallState : INSTALLSTATE
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiConfigureProductW(
        szProduct: *const u16,  // LPCWSTR
        iInstallLevel: i32,  // INSTALLLEVEL
        eInstallState: i32  // INSTALLSTATE
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiConfigureProductW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, int iInstallLevel, int eInstallState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiConfigureProductW' -Namespace Win32 -PassThru
# $api::MsiConfigureProductW(szProduct, iInstallLevel, eInstallState)
#uselib "msi.dll"
#func global MsiConfigureProductW "MsiConfigureProductW" wptr, wptr, wptr
; MsiConfigureProductW szProduct, iInstallLevel, eInstallState   ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; iInstallLevel : INSTALLLEVEL -> "wptr"
; eInstallState : INSTALLSTATE -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiConfigureProductW "MsiConfigureProductW" wstr, int, int
; res = MsiConfigureProductW(szProduct, iInstallLevel, eInstallState)
; szProduct : LPCWSTR -> "wstr"
; iInstallLevel : INSTALLLEVEL -> "int"
; eInstallState : INSTALLSTATE -> "int"
; DWORD MsiConfigureProductW(LPCWSTR szProduct, INSTALLLEVEL iInstallLevel, INSTALLSTATE eInstallState)
#uselib "msi.dll"
#cfunc global MsiConfigureProductW "MsiConfigureProductW" wstr, int, int
; res = MsiConfigureProductW(szProduct, iInstallLevel, eInstallState)
; szProduct : LPCWSTR -> "wstr"
; iInstallLevel : INSTALLLEVEL -> "int"
; eInstallState : INSTALLSTATE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiConfigureProductW = msi.NewProc("MsiConfigureProductW")
)

// szProduct (LPCWSTR), iInstallLevel (INSTALLLEVEL), eInstallState (INSTALLSTATE)
r1, _, err := procMsiConfigureProductW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
	uintptr(iInstallLevel),
	uintptr(eInstallState),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiConfigureProductW(
  szProduct: PWideChar;   // LPCWSTR
  iInstallLevel: Integer;   // INSTALLLEVEL
  eInstallState: Integer   // INSTALLSTATE
): DWORD; stdcall;
  external 'msi.dll' name 'MsiConfigureProductW';
result := DllCall("msi\MsiConfigureProductW"
    , "WStr", szProduct   ; LPCWSTR
    , "Int", iInstallLevel   ; INSTALLLEVEL
    , "Int", eInstallState   ; INSTALLSTATE
    , "UInt")   ; return: DWORD
●MsiConfigureProductW(szProduct, iInstallLevel, eInstallState) = DLL("msi.dll", "dword MsiConfigureProductW(char*, int, int)")
# 呼び出し: MsiConfigureProductW(szProduct, iInstallLevel, eInstallState)
# szProduct : LPCWSTR -> "char*"
# iInstallLevel : INSTALLLEVEL -> "int"
# eInstallState : INSTALLSTATE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。