ホーム › System.ApplicationInstallationAndServicing › MsiRemovePatchesW
MsiRemovePatchesW
関数製品から指定のパッチを削除する(Unicode版)。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiRemovePatchesW(
LPCWSTR szPatchList,
LPCWSTR szProductCode,
INSTALLTYPE eUninstallType,
LPCWSTR szPropertyList // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||
|---|---|---|---|---|---|---|---|
| szPatchList | LPCWSTR | in | 削除するパッチの一覧を表す、NULL終端文字列です。各パッチは、パッチの GUID またはパッチパッケージのフルパスで指定できます。一覧内のパッチはセミコロンで区切ります。 | ||||
| szProductCode | LPCWSTR | in | パッチの削除対象となる製品の ProductCode (GUID) を表す、NULL終端文字列です。このパラメーターを NULL にすることはできません。 | ||||
| eUninstallType | INSTALLTYPE | in | 実行するパッチ削除の種類を示す値です。このパラメーターは INSTALLTYPE_SINGLE_INSTANCE でなければなりません。
| ||||
| szPropertyList | LPCWSTR | inoptional | コマンドラインのプロパティ設定を指定する、NULL終端文字列です。詳細については、 About Properties および Setting Public Property Values on the Command Line を参照してください。このパラメーターは NULL にできます。 |
戻り値の型: DWORD
公式ドキュメント
単一の製品から1つ以上のパッチを削除します。(Unicode)
戻り値
MsiRemovePatches 関数は次の値を返します。
| 値 | 意味 |
|---|---|
| 無効なパラメーターが含まれていました。 | |
| パッチパッケージを開くことができませんでした。 | |
| パッチは正常に削除されました。 | |
| szProductList で指定された製品は、MsiRemovePatches の呼び出し元に対して、コンピューター単位でもユーザー単位でもインストールされていません。 | |
| パッチパッケージを開くことができませんでした。 | |
| パッチパッケージが無効です。 | |
| このバージョンの Windows Installer サービスではパッチパッケージを処理できません。 | |
| パッチパッケージは削除できません。 | |
| パッチはこの製品に適用されていません。 | |
| パッチの削除はポリシーによって禁止されています。 |
解説(Remarks)
アプリケーションがユーザーに対して利用可能なすべての製品からパッチを削除する方法を示す例については、Uninstalling Patches を参照してください。
メモ
msi.h ヘッダーは MsiRemovePatches を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコード中立のエイリアスの使用を、エンコード中立でないコードと混在させると、不整合が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiRemovePatchesW(
LPCWSTR szPatchList,
LPCWSTR szProductCode,
INSTALLTYPE eUninstallType,
LPCWSTR szPropertyList // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiRemovePatchesW(
[MarshalAs(UnmanagedType.LPWStr)] string szPatchList, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szProductCode, // LPCWSTR
int eUninstallType, // INSTALLTYPE
[MarshalAs(UnmanagedType.LPWStr)] string szPropertyList // LPCWSTR optional
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiRemovePatchesW(
<MarshalAs(UnmanagedType.LPWStr)> szPatchList As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szProductCode As String, ' LPCWSTR
eUninstallType As Integer, ' INSTALLTYPE
<MarshalAs(UnmanagedType.LPWStr)> szPropertyList As String ' LPCWSTR optional
) As UInteger
End Function' szPatchList : LPCWSTR
' szProductCode : LPCWSTR
' eUninstallType : INSTALLTYPE
' szPropertyList : LPCWSTR optional
Declare PtrSafe Function MsiRemovePatchesW Lib "msi" ( _
ByVal szPatchList As LongPtr, _
ByVal szProductCode As LongPtr, _
ByVal eUninstallType As Long, _
ByVal szPropertyList 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
MsiRemovePatchesW = ctypes.windll.msi.MsiRemovePatchesW
MsiRemovePatchesW.restype = wintypes.DWORD
MsiRemovePatchesW.argtypes = [
wintypes.LPCWSTR, # szPatchList : LPCWSTR
wintypes.LPCWSTR, # szProductCode : LPCWSTR
ctypes.c_int, # eUninstallType : INSTALLTYPE
wintypes.LPCWSTR, # szPropertyList : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiRemovePatchesW = Fiddle::Function.new(
lib['MsiRemovePatchesW'],
[
Fiddle::TYPE_VOIDP, # szPatchList : LPCWSTR
Fiddle::TYPE_VOIDP, # szProductCode : LPCWSTR
Fiddle::TYPE_INT, # eUninstallType : INSTALLTYPE
Fiddle::TYPE_VOIDP, # szPropertyList : LPCWSTR optional
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiRemovePatchesW(
szPatchList: *const u16, // LPCWSTR
szProductCode: *const u16, // LPCWSTR
eUninstallType: i32, // INSTALLTYPE
szPropertyList: *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 MsiRemovePatchesW([MarshalAs(UnmanagedType.LPWStr)] string szPatchList, [MarshalAs(UnmanagedType.LPWStr)] string szProductCode, int eUninstallType, [MarshalAs(UnmanagedType.LPWStr)] string szPropertyList);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiRemovePatchesW' -Namespace Win32 -PassThru
# $api::MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)#uselib "msi.dll"
#func global MsiRemovePatchesW "MsiRemovePatchesW" wptr, wptr, wptr, wptr
; MsiRemovePatchesW szPatchList, szProductCode, eUninstallType, szPropertyList ; 戻り値は stat
; szPatchList : LPCWSTR -> "wptr"
; szProductCode : LPCWSTR -> "wptr"
; eUninstallType : INSTALLTYPE -> "wptr"
; szPropertyList : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiRemovePatchesW "MsiRemovePatchesW" wstr, wstr, int, wstr
; res = MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)
; szPatchList : LPCWSTR -> "wstr"
; szProductCode : LPCWSTR -> "wstr"
; eUninstallType : INSTALLTYPE -> "int"
; szPropertyList : LPCWSTR optional -> "wstr"; DWORD MsiRemovePatchesW(LPCWSTR szPatchList, LPCWSTR szProductCode, INSTALLTYPE eUninstallType, LPCWSTR szPropertyList)
#uselib "msi.dll"
#cfunc global MsiRemovePatchesW "MsiRemovePatchesW" wstr, wstr, int, wstr
; res = MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)
; szPatchList : LPCWSTR -> "wstr"
; szProductCode : LPCWSTR -> "wstr"
; eUninstallType : INSTALLTYPE -> "int"
; szPropertyList : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiRemovePatchesW = msi.NewProc("MsiRemovePatchesW")
)
// szPatchList (LPCWSTR), szProductCode (LPCWSTR), eUninstallType (INSTALLTYPE), szPropertyList (LPCWSTR optional)
r1, _, err := procMsiRemovePatchesW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szPatchList))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCode))),
uintptr(eUninstallType),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szPropertyList))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiRemovePatchesW(
szPatchList: PWideChar; // LPCWSTR
szProductCode: PWideChar; // LPCWSTR
eUninstallType: Integer; // INSTALLTYPE
szPropertyList: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiRemovePatchesW';result := DllCall("msi\MsiRemovePatchesW"
, "WStr", szPatchList ; LPCWSTR
, "WStr", szProductCode ; LPCWSTR
, "Int", eUninstallType ; INSTALLTYPE
, "WStr", szPropertyList ; LPCWSTR optional
, "UInt") ; return: DWORD●MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList) = DLL("msi.dll", "dword MsiRemovePatchesW(char*, char*, int, char*)")
# 呼び出し: MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)
# szPatchList : LPCWSTR -> "char*"
# szProductCode : LPCWSTR -> "char*"
# eUninstallType : INSTALLTYPE -> "int"
# szPropertyList : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "msi" fn MsiRemovePatchesW(
szPatchList: [*c]const u16, // LPCWSTR
szProductCode: [*c]const u16, // LPCWSTR
eUninstallType: i32, // INSTALLTYPE
szPropertyList: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc MsiRemovePatchesW(
szPatchList: WideCString, # LPCWSTR
szProductCode: WideCString, # LPCWSTR
eUninstallType: int32, # INSTALLTYPE
szPropertyList: WideCString # LPCWSTR optional
): uint32 {.importc: "MsiRemovePatchesW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "msi");
extern(Windows)
uint MsiRemovePatchesW(
const(wchar)* szPatchList, // LPCWSTR
const(wchar)* szProductCode, // LPCWSTR
int eUninstallType, // INSTALLTYPE
const(wchar)* szPropertyList // LPCWSTR optional
);ccall((:MsiRemovePatchesW, "msi.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Int32, Cwstring),
szPatchList, szProductCode, eUninstallType, szPropertyList)
# szPatchList : LPCWSTR -> Cwstring
# szProductCode : LPCWSTR -> Cwstring
# eUninstallType : INSTALLTYPE -> Int32
# szPropertyList : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiRemovePatchesW(
const uint16_t* szPatchList,
const uint16_t* szProductCode,
int32_t eUninstallType,
const uint16_t* szPropertyList);
]]
local msi = ffi.load("msi")
-- msi.MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)
-- szPatchList : LPCWSTR
-- szProductCode : LPCWSTR
-- eUninstallType : INSTALLTYPE
-- szPropertyList : 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 MsiRemovePatchesW = lib.func('__stdcall', 'MsiRemovePatchesW', 'uint32_t', ['str16', 'str16', 'int32_t', 'str16']);
// MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)
// szPatchList : LPCWSTR -> 'str16'
// szProductCode : LPCWSTR -> 'str16'
// eUninstallType : INSTALLTYPE -> 'int32_t'
// szPropertyList : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiRemovePatchesW: { parameters: ["buffer", "buffer", "i32", "buffer"], result: "u32" },
});
// lib.symbols.MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList)
// szPatchList : LPCWSTR -> "buffer"
// szProductCode : LPCWSTR -> "buffer"
// eUninstallType : INSTALLTYPE -> "i32"
// szPropertyList : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiRemovePatchesW(
const uint16_t* szPatchList,
const uint16_t* szProductCode,
int32_t eUninstallType,
const uint16_t* szPropertyList);
C, "msi.dll");
// $ffi->MsiRemovePatchesW(szPatchList, szProductCode, eUninstallType, szPropertyList);
// szPatchList : LPCWSTR
// szProductCode : LPCWSTR
// eUninstallType : INSTALLTYPE
// szPropertyList : 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 MsiRemovePatchesW(
WString szPatchList, // LPCWSTR
WString szProductCode, // LPCWSTR
int eUninstallType, // INSTALLTYPE
WString szPropertyList // LPCWSTR optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("msi")]
lib Libmsi
fun MsiRemovePatchesW = MsiRemovePatchesW(
szPatchList : UInt16*, # LPCWSTR
szProductCode : UInt16*, # LPCWSTR
eUninstallType : Int32, # INSTALLTYPE
szPropertyList : 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 MsiRemovePatchesWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Int32, Pointer<Utf16>);
typedef MsiRemovePatchesWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Utf16>);
final MsiRemovePatchesW = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiRemovePatchesWNative, MsiRemovePatchesWDart>('MsiRemovePatchesW');
// szPatchList : LPCWSTR -> Pointer<Utf16>
// szProductCode : LPCWSTR -> Pointer<Utf16>
// eUninstallType : INSTALLTYPE -> Int32
// szPropertyList : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiRemovePatchesW(
szPatchList: PWideChar; // LPCWSTR
szProductCode: PWideChar; // LPCWSTR
eUninstallType: Integer; // INSTALLTYPE
szPropertyList: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiRemovePatchesW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiRemovePatchesW"
c_MsiRemovePatchesW :: CWString -> CWString -> Int32 -> CWString -> IO Word32
-- szPatchList : LPCWSTR -> CWString
-- szProductCode : LPCWSTR -> CWString
-- eUninstallType : INSTALLTYPE -> Int32
-- szPropertyList : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msiremovepatchesw =
foreign "MsiRemovePatchesW"
((ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> returning uint32_t)
(* szPatchList : LPCWSTR -> (ptr uint16_t) *)
(* szProductCode : LPCWSTR -> (ptr uint16_t) *)
(* eUninstallType : INSTALLTYPE -> int32_t *)
(* szPropertyList : 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 ("MsiRemovePatchesW" msi-remove-patches-w :convention :stdcall) :uint32
(sz-patch-list (:string :encoding :utf-16le)) ; LPCWSTR
(sz-product-code (:string :encoding :utf-16le)) ; LPCWSTR
(e-uninstall-type :int32) ; INSTALLTYPE
(sz-property-list (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiRemovePatchesW = Win32::API::More->new('msi',
'DWORD MsiRemovePatchesW(LPCWSTR szPatchList, LPCWSTR szProductCode, int eUninstallType, LPCWSTR szPropertyList)');
# my $ret = $MsiRemovePatchesW->Call($szPatchList, $szProductCode, $eUninstallType, $szPropertyList);
# szPatchList : LPCWSTR -> LPCWSTR
# szProductCode : LPCWSTR -> LPCWSTR
# eUninstallType : INSTALLTYPE -> int
# szPropertyList : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f MsiRemovePatchesA (ANSI版) — 製品から指定のパッチを削除する(ANSI版)。
公式の関連項目
- f MsiApplyPatchW — 製品にパッチパッケージを適用する(Unicode版)。
使用する型