MsiGetPatchFileListA
関数シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiGetPatchFileListA(
LPCSTR szProductCode,
LPCSTR szPatchPackages,
DWORD* pcFiles,
MSIHANDLE** pphFileRecords
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| szProductCode | LPCSTR | in | パッチの対象となる製品の ProductCode(GUID)を格納した、null で終わる文字列値です。このパラメーターを NULL にすることはできません。 |
| szPatchPackages | LPCSTR | in | Windows Installer のパッチ(.msp ファイル)のリストを格納した、null で終わる文字列値です。各パッチはパッチ パッケージへのフル パスで指定できます。リスト内のパッチはセミコロンで区切ります。少なくとも 1 つのパッチを指定する必要があります。 |
| pcFiles | DWORD* | out | szPatchList で指定されたパッチのリストによって、このシステム上で更新されるファイルの数を受け取る場所へのポインターです。このパラメーターは必須です。 |
| pphFileRecords | MSIHANDLE** | out | レコードの配列へのポインターを受け取る場所へのポインターです。各レコードの最初のフィールド(インデックス 0)には、szPatchList 内のパッチのリストがこのコンピューター上で適用されたときに更新可能なファイルのフル パスが格納されます。このパラメーターは必須です。 |
戻り値の型: DWORD
公式ドキュメント
MsiGetPatchFileList 関数は、セミコロンで区切られた .msp ファイルのリストを受け取り、それらのパッチによって更新可能なファイルの一覧を取得します。(ANSI)
戻り値
MsiGetPatchFileList 関数は、次の値を返します。
| 値 | 意味 |
|---|---|
| 関数は正常に完了しました。 | |
| 無効なパラメーターが関数に渡されました。 | |
| 関数が失敗しました。 |
解説(Remarks)
たとえば、szPatchList には次のような値を指定できます: "c:\sus\download\cache\Office\sp1.msp; c:\sus\download\cache\Office\QFE1.msp; c:\sus\download\cache\Office\QFEn.msp"。
この関数は呼び出し元のコンテキストで実行されます。製品コードは、ユーザー非管理コンテキスト、ユーザー管理コンテキスト、マシン コンテキストの順に検索されます。
この関数によって返されるすべての MSIHANDLE オブジェクトは、MsiCloseHandle 関数を呼び出して閉じる必要があります。
関数が失敗した場合は、MsiGetLastErrorRecord 関数を使用して拡張エラー情報を取得できます。
MsiGetPatchFileList 関数の使用方法の詳細については、Listing the Files that can be Updated を参照してください。
msi.h ヘッダーは MsiGetPatchFileList を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスを、エンコーディング非依存ではないコードと混在させて使用すると、不一致が生じてコンパイル エラーや実行時エラーの原因となることがあります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiGetPatchFileListA(
LPCSTR szProductCode,
LPCSTR szPatchPackages,
DWORD* pcFiles,
MSIHANDLE** pphFileRecords
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetPatchFileListA(
[MarshalAs(UnmanagedType.LPStr)] string szProductCode, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szPatchPackages, // LPCSTR
out uint pcFiles, // DWORD* out
IntPtr pphFileRecords // MSIHANDLE** out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetPatchFileListA(
<MarshalAs(UnmanagedType.LPStr)> szProductCode As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szPatchPackages As String, ' LPCSTR
<Out> ByRef pcFiles As UInteger, ' DWORD* out
pphFileRecords As IntPtr ' MSIHANDLE** out
) As UInteger
End Function' szProductCode : LPCSTR
' szPatchPackages : LPCSTR
' pcFiles : DWORD* out
' pphFileRecords : MSIHANDLE** out
Declare PtrSafe Function MsiGetPatchFileListA Lib "msi" ( _
ByVal szProductCode As String, _
ByVal szPatchPackages As String, _
ByRef pcFiles As Long, _
ByVal pphFileRecords As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiGetPatchFileListA = ctypes.windll.msi.MsiGetPatchFileListA
MsiGetPatchFileListA.restype = wintypes.DWORD
MsiGetPatchFileListA.argtypes = [
wintypes.LPCSTR, # szProductCode : LPCSTR
wintypes.LPCSTR, # szPatchPackages : LPCSTR
ctypes.POINTER(wintypes.DWORD), # pcFiles : DWORD* out
ctypes.c_void_p, # pphFileRecords : MSIHANDLE** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetPatchFileListA = Fiddle::Function.new(
lib['MsiGetPatchFileListA'],
[
Fiddle::TYPE_VOIDP, # szProductCode : LPCSTR
Fiddle::TYPE_VOIDP, # szPatchPackages : LPCSTR
Fiddle::TYPE_VOIDP, # pcFiles : DWORD* out
Fiddle::TYPE_VOIDP, # pphFileRecords : MSIHANDLE** out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiGetPatchFileListA(
szProductCode: *const u8, // LPCSTR
szPatchPackages: *const u8, // LPCSTR
pcFiles: *mut u32, // DWORD* out
pphFileRecords: *mut *mut u32 // MSIHANDLE** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiGetPatchFileListA([MarshalAs(UnmanagedType.LPStr)] string szProductCode, [MarshalAs(UnmanagedType.LPStr)] string szPatchPackages, out uint pcFiles, IntPtr pphFileRecords);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetPatchFileListA' -Namespace Win32 -PassThru
# $api::MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords)#uselib "msi.dll"
#func global MsiGetPatchFileListA "MsiGetPatchFileListA" sptr, sptr, sptr, sptr
; MsiGetPatchFileListA szProductCode, szPatchPackages, varptr(pcFiles), varptr(pphFileRecords) ; 戻り値は stat
; szProductCode : LPCSTR -> "sptr"
; szPatchPackages : LPCSTR -> "sptr"
; pcFiles : DWORD* out -> "sptr"
; pphFileRecords : MSIHANDLE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll" #cfunc global MsiGetPatchFileListA "MsiGetPatchFileListA" str, str, var, var ; res = MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords) ; szProductCode : LPCSTR -> "str" ; szPatchPackages : LPCSTR -> "str" ; pcFiles : DWORD* out -> "var" ; pphFileRecords : MSIHANDLE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiGetPatchFileListA "MsiGetPatchFileListA" str, str, sptr, sptr ; res = MsiGetPatchFileListA(szProductCode, szPatchPackages, varptr(pcFiles), varptr(pphFileRecords)) ; szProductCode : LPCSTR -> "str" ; szPatchPackages : LPCSTR -> "str" ; pcFiles : DWORD* out -> "sptr" ; pphFileRecords : MSIHANDLE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; DWORD MsiGetPatchFileListA(LPCSTR szProductCode, LPCSTR szPatchPackages, DWORD* pcFiles, MSIHANDLE** pphFileRecords) #uselib "msi.dll" #cfunc global MsiGetPatchFileListA "MsiGetPatchFileListA" str, str, var, var ; res = MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords) ; szProductCode : LPCSTR -> "str" ; szPatchPackages : LPCSTR -> "str" ; pcFiles : DWORD* out -> "var" ; pphFileRecords : MSIHANDLE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiGetPatchFileListA(LPCSTR szProductCode, LPCSTR szPatchPackages, DWORD* pcFiles, MSIHANDLE** pphFileRecords) #uselib "msi.dll" #cfunc global MsiGetPatchFileListA "MsiGetPatchFileListA" str, str, intptr, intptr ; res = MsiGetPatchFileListA(szProductCode, szPatchPackages, varptr(pcFiles), varptr(pphFileRecords)) ; szProductCode : LPCSTR -> "str" ; szPatchPackages : LPCSTR -> "str" ; pcFiles : DWORD* out -> "intptr" ; pphFileRecords : MSIHANDLE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiGetPatchFileListA = msi.NewProc("MsiGetPatchFileListA")
)
// szProductCode (LPCSTR), szPatchPackages (LPCSTR), pcFiles (DWORD* out), pphFileRecords (MSIHANDLE** out)
r1, _, err := procMsiGetPatchFileListA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProductCode))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szPatchPackages))),
uintptr(pcFiles),
uintptr(pphFileRecords),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiGetPatchFileListA(
szProductCode: PAnsiChar; // LPCSTR
szPatchPackages: PAnsiChar; // LPCSTR
pcFiles: Pointer; // DWORD* out
pphFileRecords: Pointer // MSIHANDLE** out
): DWORD; stdcall;
external 'msi.dll' name 'MsiGetPatchFileListA';result := DllCall("msi\MsiGetPatchFileListA"
, "AStr", szProductCode ; LPCSTR
, "AStr", szPatchPackages ; LPCSTR
, "Ptr", pcFiles ; DWORD* out
, "Ptr", pphFileRecords ; MSIHANDLE** out
, "UInt") ; return: DWORD●MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords) = DLL("msi.dll", "dword MsiGetPatchFileListA(char*, char*, void*, void*)")
# 呼び出し: MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords)
# szProductCode : LPCSTR -> "char*"
# szPatchPackages : LPCSTR -> "char*"
# pcFiles : DWORD* out -> "void*"
# pphFileRecords : MSIHANDLE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiGetPatchFileListA(
szProductCode: [*c]const u8, // LPCSTR
szPatchPackages: [*c]const u8, // LPCSTR
pcFiles: [*c]u32, // DWORD* out
pphFileRecords: [*c][*c]u32 // MSIHANDLE** out
) callconv(std.os.windows.WINAPI) u32;proc MsiGetPatchFileListA(
szProductCode: cstring, # LPCSTR
szPatchPackages: cstring, # LPCSTR
pcFiles: ptr uint32, # DWORD* out
pphFileRecords: ptr uint32 # MSIHANDLE** out
): uint32 {.importc: "MsiGetPatchFileListA", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiGetPatchFileListA(
const(char)* szProductCode, // LPCSTR
const(char)* szPatchPackages, // LPCSTR
uint* pcFiles, // DWORD* out
uint** pphFileRecords // MSIHANDLE** out
);ccall((:MsiGetPatchFileListA, "msi.dll"), stdcall, UInt32,
(Cstring, Cstring, Ptr{UInt32}, Ptr{UInt32}),
szProductCode, szPatchPackages, pcFiles, pphFileRecords)
# szProductCode : LPCSTR -> Cstring
# szPatchPackages : LPCSTR -> Cstring
# pcFiles : DWORD* out -> Ptr{UInt32}
# pphFileRecords : MSIHANDLE** out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiGetPatchFileListA(
const char* szProductCode,
const char* szPatchPackages,
uint32_t* pcFiles,
uint32_t** pphFileRecords);
]]
local msi = ffi.load("msi")
-- msi.MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords)
-- szProductCode : LPCSTR
-- szPatchPackages : LPCSTR
-- pcFiles : DWORD* out
-- pphFileRecords : MSIHANDLE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiGetPatchFileListA = lib.func('__stdcall', 'MsiGetPatchFileListA', 'uint32_t', ['str', 'str', 'uint32_t *', 'uint32_t *']);
// MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords)
// szProductCode : LPCSTR -> 'str'
// szPatchPackages : LPCSTR -> 'str'
// pcFiles : DWORD* out -> 'uint32_t *'
// pphFileRecords : MSIHANDLE** out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiGetPatchFileListA: { parameters: ["buffer", "buffer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords)
// szProductCode : LPCSTR -> "buffer"
// szPatchPackages : LPCSTR -> "buffer"
// pcFiles : DWORD* out -> "pointer"
// pphFileRecords : MSIHANDLE** out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiGetPatchFileListA(
const char* szProductCode,
const char* szPatchPackages,
uint32_t* pcFiles,
uint32_t** pphFileRecords);
C, "msi.dll");
// $ffi->MsiGetPatchFileListA(szProductCode, szPatchPackages, pcFiles, pphFileRecords);
// szProductCode : LPCSTR
// szPatchPackages : LPCSTR
// pcFiles : DWORD* out
// pphFileRecords : MSIHANDLE** out
// 構造体/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.ASCII_OPTIONS);
int MsiGetPatchFileListA(
String szProductCode, // LPCSTR
String szPatchPackages, // LPCSTR
IntByReference pcFiles, // DWORD* out
Pointer pphFileRecords // MSIHANDLE** out
);
}@[Link("msi")]
lib Libmsi
fun MsiGetPatchFileListA = MsiGetPatchFileListA(
szProductCode : UInt8*, # LPCSTR
szPatchPackages : UInt8*, # LPCSTR
pcFiles : UInt32*, # DWORD* out
pphFileRecords : UInt32** # MSIHANDLE** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiGetPatchFileListANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Uint32>, Pointer<Uint32>);
typedef MsiGetPatchFileListADart = int Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Uint32>, Pointer<Uint32>);
final MsiGetPatchFileListA = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiGetPatchFileListANative, MsiGetPatchFileListADart>('MsiGetPatchFileListA');
// szProductCode : LPCSTR -> Pointer<Utf8>
// szPatchPackages : LPCSTR -> Pointer<Utf8>
// pcFiles : DWORD* out -> Pointer<Uint32>
// pphFileRecords : MSIHANDLE** out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiGetPatchFileListA(
szProductCode: PAnsiChar; // LPCSTR
szPatchPackages: PAnsiChar; // LPCSTR
pcFiles: Pointer; // DWORD* out
pphFileRecords: Pointer // MSIHANDLE** out
): DWORD; stdcall;
external 'msi.dll' name 'MsiGetPatchFileListA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiGetPatchFileListA"
c_MsiGetPatchFileListA :: CString -> CString -> Ptr Word32 -> Ptr Word32 -> IO Word32
-- szProductCode : LPCSTR -> CString
-- szPatchPackages : LPCSTR -> CString
-- pcFiles : DWORD* out -> Ptr Word32
-- pphFileRecords : MSIHANDLE** out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msigetpatchfilelista =
foreign "MsiGetPatchFileListA"
(string @-> string @-> (ptr uint32_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* szProductCode : LPCSTR -> string *)
(* szPatchPackages : LPCSTR -> string *)
(* pcFiles : DWORD* out -> (ptr uint32_t) *)
(* pphFileRecords : MSIHANDLE** out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiGetPatchFileListA" msi-get-patch-file-list-a :convention :stdcall) :uint32
(sz-product-code :string) ; LPCSTR
(sz-patch-packages :string) ; LPCSTR
(pc-files :pointer) ; DWORD* out
(pph-file-records :pointer)) ; MSIHANDLE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiGetPatchFileListA = Win32::API::More->new('msi',
'DWORD MsiGetPatchFileListA(LPCSTR szProductCode, LPCSTR szPatchPackages, LPVOID pcFiles, LPVOID pphFileRecords)');
# my $ret = $MsiGetPatchFileListA->Call($szProductCode, $szPatchPackages, $pcFiles, $pphFileRecords);
# szProductCode : LPCSTR -> LPCSTR
# szPatchPackages : LPCSTR -> LPCSTR
# pcFiles : DWORD* out -> LPVOID
# pphFileRecords : MSIHANDLE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f MsiGetPatchFileListW (Unicode版) — パッチパッケージが変更するファイルの一覧をレコードとして取得する。