ホーム › System.ApplicationInstallationAndServicing › MsiApplyPatchW
MsiApplyPatchW
関数製品にパッチパッケージを適用する(Unicode版)。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiApplyPatchW(
LPCWSTR szPatchPackage,
LPCWSTR szInstallPackage, // optional
INSTALLTYPE eInstallType,
LPCWSTR szCommandLine // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szPatchPackage | LPCWSTR | in |
| szInstallPackage | LPCWSTR | inoptional |
| eInstallType | INSTALLTYPE | in |
| szCommandLine | LPCWSTR | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiApplyPatchW(
LPCWSTR szPatchPackage,
LPCWSTR szInstallPackage, // optional
INSTALLTYPE eInstallType,
LPCWSTR szCommandLine // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiApplyPatchW(
[MarshalAs(UnmanagedType.LPWStr)] string szPatchPackage, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szInstallPackage, // LPCWSTR optional
int eInstallType, // INSTALLTYPE
[MarshalAs(UnmanagedType.LPWStr)] string szCommandLine // LPCWSTR optional
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiApplyPatchW(
<MarshalAs(UnmanagedType.LPWStr)> szPatchPackage As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szInstallPackage As String, ' LPCWSTR optional
eInstallType As Integer, ' INSTALLTYPE
<MarshalAs(UnmanagedType.LPWStr)> szCommandLine As String ' LPCWSTR optional
) As UInteger
End Function' szPatchPackage : LPCWSTR
' szInstallPackage : LPCWSTR optional
' eInstallType : INSTALLTYPE
' szCommandLine : LPCWSTR optional
Declare PtrSafe Function MsiApplyPatchW Lib "msi" ( _
ByVal szPatchPackage As LongPtr, _
ByVal szInstallPackage As LongPtr, _
ByVal eInstallType 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
MsiApplyPatchW = ctypes.windll.msi.MsiApplyPatchW
MsiApplyPatchW.restype = wintypes.DWORD
MsiApplyPatchW.argtypes = [
wintypes.LPCWSTR, # szPatchPackage : LPCWSTR
wintypes.LPCWSTR, # szInstallPackage : LPCWSTR optional
ctypes.c_int, # eInstallType : INSTALLTYPE
wintypes.LPCWSTR, # szCommandLine : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiApplyPatchW = Fiddle::Function.new(
lib['MsiApplyPatchW'],
[
Fiddle::TYPE_VOIDP, # szPatchPackage : LPCWSTR
Fiddle::TYPE_VOIDP, # szInstallPackage : LPCWSTR optional
Fiddle::TYPE_INT, # eInstallType : INSTALLTYPE
Fiddle::TYPE_VOIDP, # szCommandLine : LPCWSTR optional
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiApplyPatchW(
szPatchPackage: *const u16, // LPCWSTR
szInstallPackage: *const u16, // LPCWSTR optional
eInstallType: i32, // INSTALLTYPE
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 MsiApplyPatchW([MarshalAs(UnmanagedType.LPWStr)] string szPatchPackage, [MarshalAs(UnmanagedType.LPWStr)] string szInstallPackage, int eInstallType, [MarshalAs(UnmanagedType.LPWStr)] string szCommandLine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiApplyPatchW' -Namespace Win32 -PassThru
# $api::MsiApplyPatchW(szPatchPackage, szInstallPackage, eInstallType, szCommandLine)#uselib "msi.dll"
#func global MsiApplyPatchW "MsiApplyPatchW" wptr, wptr, wptr, wptr
; MsiApplyPatchW szPatchPackage, szInstallPackage, eInstallType, szCommandLine ; 戻り値は stat
; szPatchPackage : LPCWSTR -> "wptr"
; szInstallPackage : LPCWSTR optional -> "wptr"
; eInstallType : INSTALLTYPE -> "wptr"
; szCommandLine : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiApplyPatchW "MsiApplyPatchW" wstr, wstr, int, wstr
; res = MsiApplyPatchW(szPatchPackage, szInstallPackage, eInstallType, szCommandLine)
; szPatchPackage : LPCWSTR -> "wstr"
; szInstallPackage : LPCWSTR optional -> "wstr"
; eInstallType : INSTALLTYPE -> "int"
; szCommandLine : LPCWSTR optional -> "wstr"; DWORD MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage, INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
#uselib "msi.dll"
#cfunc global MsiApplyPatchW "MsiApplyPatchW" wstr, wstr, int, wstr
; res = MsiApplyPatchW(szPatchPackage, szInstallPackage, eInstallType, szCommandLine)
; szPatchPackage : LPCWSTR -> "wstr"
; szInstallPackage : LPCWSTR optional -> "wstr"
; eInstallType : INSTALLTYPE -> "int"
; szCommandLine : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiApplyPatchW = msi.NewProc("MsiApplyPatchW")
)
// szPatchPackage (LPCWSTR), szInstallPackage (LPCWSTR optional), eInstallType (INSTALLTYPE), szCommandLine (LPCWSTR optional)
r1, _, err := procMsiApplyPatchW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szPatchPackage))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szInstallPackage))),
uintptr(eInstallType),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szCommandLine))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiApplyPatchW(
szPatchPackage: PWideChar; // LPCWSTR
szInstallPackage: PWideChar; // LPCWSTR optional
eInstallType: Integer; // INSTALLTYPE
szCommandLine: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiApplyPatchW';result := DllCall("msi\MsiApplyPatchW"
, "WStr", szPatchPackage ; LPCWSTR
, "WStr", szInstallPackage ; LPCWSTR optional
, "Int", eInstallType ; INSTALLTYPE
, "WStr", szCommandLine ; LPCWSTR optional
, "UInt") ; return: DWORD●MsiApplyPatchW(szPatchPackage, szInstallPackage, eInstallType, szCommandLine) = DLL("msi.dll", "dword MsiApplyPatchW(char*, char*, int, char*)")
# 呼び出し: MsiApplyPatchW(szPatchPackage, szInstallPackage, eInstallType, szCommandLine)
# szPatchPackage : LPCWSTR -> "char*"
# szInstallPackage : LPCWSTR optional -> "char*"
# eInstallType : INSTALLTYPE -> "int"
# szCommandLine : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。