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

MsiApplyMultiplePatchesW

関数
複数のパッチを一括して製品に適用する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiApplyMultiplePatchesW(
    LPCWSTR szPatchPackages,
    LPCWSTR szProductCode,   // optional
    LPCWSTR szPropertiesList   // optional
);

パラメーター

名前方向説明
szPatchPackagesLPCWSTRinパッチファイルへのパスをセミコロン区切りで列挙した単一の文字列です。例: ""c:\sus\download\cache\Office\sp1.msp; c:\sus\download\cache\Office\QFE1.msp; c:\sus\download\cache\Office\QFEn.msp" "
szProductCodeLPCWSTRinoptionalこのパラメーターは、パッチを適用する製品の ProductCode GUID です。MsiApplyMultiplePatches を呼び出すユーザーまたはアプリケーションは、パッチを適用する権限を持っている必要があります。このパラメーターが NULL の場合、パッチは資格のあるすべての製品に適用されます。このパラメーターが NULL 以外の場合、パッチは指定された製品にのみ適用されます。
szPropertiesListLPCWSTRinoptional

製品へのパッチ適用時に使用するコマンドラインのプロパティ設定を指定する、null で終わる文字列です。コマンドラインのプロパティ設定がない場合は、NULL ポインターを渡します。空文字列は無効なパラメーターです。これらのプロパティは、すべての対象製品で共有されます。詳細については、 About Properties および Setting Public Property Values on the Command Line を参照してください。

Note プロパティリストには PATCH プロパティを含めないでください。コマンドラインで PATCH プロパティが設定されていても、その値は無視され、適用されるパッチで上書きされます。

戻り値の型: DWORD

公式ドキュメント

パッチを受け取る資格のある製品に対して、1 つ以上のパッチを適用します。(Unicode)

戻り値

MsiApplyMultiplePatches 関数は、次の値を返します。

意味
ERROR_INVALID_PARAMETER
渡された引数の一部が正しくないか、矛盾しています。
ERROR_SUCCESS
関数が完了し、すべての製品が正常にパッチされました。ERROR_SUCCESS は、パッチの資格を持つすべての製品が正常にパッチされた場合にのみ返されます。新しいパッチがいずれも適用対象でない場合、MsiApplyMultiplePatchesERROR_SUCCESS を返し、製品の状態は変更されません。
ERROR_SUCCESS_REBOOT_INITIATED
直前のトランザクションによって開始された再起動により、この MsiApplyMultiplePatches の呼び出しが終了しました。すべての対象製品がパッチされていない可能性があります。
ERROR_SUCCESS_REBOOT_REQUIRED
直前のトランザクションによって要求された再起動により、この MsiApplyMultiplePatches の呼び出しが終了しました。すべての対象製品がパッチされていない可能性があります。
ERROR_PATCH_PACKAGE_OPEN_FAILED
指定されたパッチパッケージの 1 つを開けませんでした。
ERROR_PATCH_PACKAGE_INVALID
指定されたパッチパッケージの 1 つが有効ではありません。
ERROR_PATCH_PACKAGE_UNSUPPORTED
パッチパッケージの 1 つがサポートされていません。
Winerror.h 内の任意のエラー
部分的に完了した可能性があるか、1 つ以上のトランザクションが失敗したことを示します。

解説(Remarks)

メモ

msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiApplyMultiplePatches を定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

DWORD MsiApplyMultiplePatchesW(
    LPCWSTR szPatchPackages,
    LPCWSTR szProductCode,   // optional
    LPCWSTR szPropertiesList   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiApplyMultiplePatchesW(
    [MarshalAs(UnmanagedType.LPWStr)] string szPatchPackages,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szProductCode,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string szPropertiesList   // LPCWSTR optional
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiApplyMultiplePatchesW(
    <MarshalAs(UnmanagedType.LPWStr)> szPatchPackages As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szProductCode As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> szPropertiesList As String   ' LPCWSTR optional
) As UInteger
End Function
' szPatchPackages : LPCWSTR
' szProductCode : LPCWSTR optional
' szPropertiesList : LPCWSTR optional
Declare PtrSafe Function MsiApplyMultiplePatchesW Lib "msi" ( _
    ByVal szPatchPackages As LongPtr, _
    ByVal szProductCode As LongPtr, _
    ByVal szPropertiesList 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

MsiApplyMultiplePatchesW = ctypes.windll.msi.MsiApplyMultiplePatchesW
MsiApplyMultiplePatchesW.restype = wintypes.DWORD
MsiApplyMultiplePatchesW.argtypes = [
    wintypes.LPCWSTR,  # szPatchPackages : LPCWSTR
    wintypes.LPCWSTR,  # szProductCode : LPCWSTR optional
    wintypes.LPCWSTR,  # szPropertiesList : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiApplyMultiplePatchesW = Fiddle::Function.new(
  lib['MsiApplyMultiplePatchesW'],
  [
    Fiddle::TYPE_VOIDP,  # szPatchPackages : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szProductCode : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # szPropertiesList : LPCWSTR optional
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiApplyMultiplePatchesW(
        szPatchPackages: *const u16,  // LPCWSTR
        szProductCode: *const u16,  // LPCWSTR optional
        szPropertiesList: *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 MsiApplyMultiplePatchesW([MarshalAs(UnmanagedType.LPWStr)] string szPatchPackages, [MarshalAs(UnmanagedType.LPWStr)] string szProductCode, [MarshalAs(UnmanagedType.LPWStr)] string szPropertiesList);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiApplyMultiplePatchesW' -Namespace Win32 -PassThru
# $api::MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList)
#uselib "msi.dll"
#func global MsiApplyMultiplePatchesW "MsiApplyMultiplePatchesW" wptr, wptr, wptr
; MsiApplyMultiplePatchesW szPatchPackages, szProductCode, szPropertiesList   ; 戻り値は stat
; szPatchPackages : LPCWSTR -> "wptr"
; szProductCode : LPCWSTR optional -> "wptr"
; szPropertiesList : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiApplyMultiplePatchesW "MsiApplyMultiplePatchesW" wstr, wstr, wstr
; res = MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList)
; szPatchPackages : LPCWSTR -> "wstr"
; szProductCode : LPCWSTR optional -> "wstr"
; szPropertiesList : LPCWSTR optional -> "wstr"
; DWORD MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages, LPCWSTR szProductCode, LPCWSTR szPropertiesList)
#uselib "msi.dll"
#cfunc global MsiApplyMultiplePatchesW "MsiApplyMultiplePatchesW" wstr, wstr, wstr
; res = MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList)
; szPatchPackages : LPCWSTR -> "wstr"
; szProductCode : LPCWSTR optional -> "wstr"
; szPropertiesList : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiApplyMultiplePatchesW = msi.NewProc("MsiApplyMultiplePatchesW")
)

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

extern "msi" fn MsiApplyMultiplePatchesW(
    szPatchPackages: [*c]const u16, // LPCWSTR
    szProductCode: [*c]const u16, // LPCWSTR optional
    szPropertiesList: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc MsiApplyMultiplePatchesW(
    szPatchPackages: WideCString,  # LPCWSTR
    szProductCode: WideCString,  # LPCWSTR optional
    szPropertiesList: WideCString  # LPCWSTR optional
): uint32 {.importc: "MsiApplyMultiplePatchesW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "msi");
extern(Windows)
uint MsiApplyMultiplePatchesW(
    const(wchar)* szPatchPackages,   // LPCWSTR
    const(wchar)* szProductCode,   // LPCWSTR optional
    const(wchar)* szPropertiesList   // LPCWSTR optional
);
ccall((:MsiApplyMultiplePatchesW, "msi.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, Cwstring),
      szPatchPackages, szProductCode, szPropertiesList)
# szPatchPackages : LPCWSTR -> Cwstring
# szProductCode : LPCWSTR optional -> Cwstring
# szPropertiesList : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiApplyMultiplePatchesW(
    const uint16_t* szPatchPackages,
    const uint16_t* szProductCode,
    const uint16_t* szPropertiesList);
]]
local msi = ffi.load("msi")
-- msi.MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList)
-- szPatchPackages : LPCWSTR
-- szProductCode : LPCWSTR optional
-- szPropertiesList : 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 MsiApplyMultiplePatchesW = lib.func('__stdcall', 'MsiApplyMultiplePatchesW', 'uint32_t', ['str16', 'str16', 'str16']);
// MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList)
// szPatchPackages : LPCWSTR -> 'str16'
// szProductCode : LPCWSTR optional -> 'str16'
// szPropertiesList : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msi.dll", {
  MsiApplyMultiplePatchesW: { parameters: ["buffer", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList)
// szPatchPackages : LPCWSTR -> "buffer"
// szProductCode : LPCWSTR optional -> "buffer"
// szPropertiesList : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiApplyMultiplePatchesW(
    const uint16_t* szPatchPackages,
    const uint16_t* szProductCode,
    const uint16_t* szPropertiesList);
C, "msi.dll");
// $ffi->MsiApplyMultiplePatchesW(szPatchPackages, szProductCode, szPropertiesList);
// szPatchPackages : LPCWSTR
// szProductCode : LPCWSTR optional
// szPropertiesList : 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 MsiApplyMultiplePatchesW(
        WString szPatchPackages,   // LPCWSTR
        WString szProductCode,   // LPCWSTR optional
        WString szPropertiesList   // LPCWSTR optional
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("msi")]
lib Libmsi
  fun MsiApplyMultiplePatchesW = MsiApplyMultiplePatchesW(
    szPatchPackages : UInt16*,   # LPCWSTR
    szProductCode : UInt16*,   # LPCWSTR optional
    szPropertiesList : 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 MsiApplyMultiplePatchesWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef MsiApplyMultiplePatchesWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final MsiApplyMultiplePatchesW = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiApplyMultiplePatchesWNative, MsiApplyMultiplePatchesWDart>('MsiApplyMultiplePatchesW');
// szPatchPackages : LPCWSTR -> Pointer<Utf16>
// szProductCode : LPCWSTR optional -> Pointer<Utf16>
// szPropertiesList : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiApplyMultiplePatchesW(
  szPatchPackages: PWideChar;   // LPCWSTR
  szProductCode: PWideChar;   // LPCWSTR optional
  szPropertiesList: PWideChar   // LPCWSTR optional
): DWORD; stdcall;
  external 'msi.dll' name 'MsiApplyMultiplePatchesW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiApplyMultiplePatchesW"
  c_MsiApplyMultiplePatchesW :: CWString -> CWString -> CWString -> IO Word32
-- szPatchPackages : LPCWSTR -> CWString
-- szProductCode : LPCWSTR optional -> CWString
-- szPropertiesList : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msiapplymultiplepatchesw =
  foreign "MsiApplyMultiplePatchesW"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* szPatchPackages : LPCWSTR -> (ptr uint16_t) *)
(* szProductCode : LPCWSTR optional -> (ptr uint16_t) *)
(* szPropertiesList : 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 ("MsiApplyMultiplePatchesW" msi-apply-multiple-patches-w :convention :stdcall) :uint32
  (sz-patch-packages (:string :encoding :utf-16le))   ; LPCWSTR
  (sz-product-code (:string :encoding :utf-16le))   ; LPCWSTR optional
  (sz-properties-list (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiApplyMultiplePatchesW = Win32::API::More->new('msi',
    'DWORD MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages, LPCWSTR szProductCode, LPCWSTR szPropertiesList)');
# my $ret = $MsiApplyMultiplePatchesW->Call($szPatchPackages, $szProductCode, $szPropertiesList);
# szPatchPackages : LPCWSTR -> LPCWSTR
# szProductCode : LPCWSTR optional -> LPCWSTR
# szPropertiesList : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い