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

MsiInstallProductA

関数
MSIパッケージから製品をインストールする(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiInstallProductA(
    LPCSTR szPackagePath,
    LPCSTR szCommandLine   // optional
);

パラメーター

名前方向
szPackagePathLPCSTRin
szCommandLineLPCSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MsiInstallProductA = ctypes.windll.msi.MsiInstallProductA
MsiInstallProductA.restype = wintypes.DWORD
MsiInstallProductA.argtypes = [
    wintypes.LPCSTR,  # szPackagePath : LPCSTR
    wintypes.LPCSTR,  # szCommandLine : LPCSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiInstallProductA = Fiddle::Function.new(
  lib['MsiInstallProductA'],
  [
    Fiddle::TYPE_VOIDP,  # szPackagePath : LPCSTR
    Fiddle::TYPE_VOIDP,  # szCommandLine : LPCSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiInstallProductA(
        szPackagePath: *const u8,  // LPCSTR
        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 MsiInstallProductA([MarshalAs(UnmanagedType.LPStr)] string szPackagePath, [MarshalAs(UnmanagedType.LPStr)] string szCommandLine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiInstallProductA' -Namespace Win32 -PassThru
# $api::MsiInstallProductA(szPackagePath, szCommandLine)
#uselib "msi.dll"
#func global MsiInstallProductA "MsiInstallProductA" sptr, sptr
; MsiInstallProductA szPackagePath, szCommandLine   ; 戻り値は stat
; szPackagePath : LPCSTR -> "sptr"
; szCommandLine : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiInstallProductA "MsiInstallProductA" str, str
; res = MsiInstallProductA(szPackagePath, szCommandLine)
; szPackagePath : LPCSTR -> "str"
; szCommandLine : LPCSTR optional -> "str"
; DWORD MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
#uselib "msi.dll"
#cfunc global MsiInstallProductA "MsiInstallProductA" str, str
; res = MsiInstallProductA(szPackagePath, szCommandLine)
; szPackagePath : LPCSTR -> "str"
; szCommandLine : LPCSTR optional -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiInstallProductA = msi.NewProc("MsiInstallProductA")
)

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