MsiEnumPatchesExA
関数シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiEnumPatchesExA(
LPCSTR szProductCode, // optional
LPCSTR szUserSid, // optional
DWORD dwContext,
DWORD dwFilter,
DWORD dwIndex,
LPSTR szPatchCode, // optional
LPSTR szTargetProductCode, // optional
MSIINSTALLCONTEXT* pdwTargetProductContext, // optional
LPSTR szTargetUserSid, // optional
DWORD* pcchTargetUserSid // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| szProductCode | LPCSTR | inoptional | パッチを列挙する製品の ProductCode GUID を指定する null 終端文字列です。NULL 以外の場合、パッチの列挙は、szUserSid および dwContext で指定されたユーザーとコンテキストの下にあるこの製品のインスタンスに限定されます。NULL の場合、指定されたコンテキストの下にあるすべての製品のパッチが列挙されます。 | ||||||||||||
| szUserSid | LPCSTR | inoptional | 列挙のコンテキストを制限するセキュリティ識別子 (SID) を指定する null 終端文字列です。特別な SID 文字列 "S-1-1-0" (Everyone) は、システム内のすべてのユーザーにわたる列挙を指定します。"S-1-1-0" 以外の SID 値はユーザー SID と見なされ、列挙をそのユーザーに限定します。現在のユーザー以外のユーザーを列挙する場合、Windows Installer バージョン 3.0 より前のバージョンを使用してユーザー単位の非管理コンテキストで適用されたパッチは列挙されません。このパラメーターを NULL に設定すると、現在のユーザーを指定できます。
注 特別な SID 文字列 "S-1-5-18" (System) は、コンピューター単位でインストールされた製品やパッチを列挙するために使用することはできません。SID 値を "S-1-5-18" に設定すると、ERROR_INVALID_PARAMETER が返されます。dwContext を MSIINSTALLCONTEXT_MACHINE のみに設定する場合、szUserSid は NULL でなければなりません。
| ||||||||||||
| dwContext | DWORD | in | 列挙を 1 つまたは複数のコンテキストの組み合わせに制限します。このパラメーターには、次の値のいずれか 1 つまたは組み合わせを指定できます。
| ||||||||||||
| dwFilter | DWORD | in | 列挙のフィルターです。このパラメーターには、次のパラメーターのいずれか 1 つまたは組み合わせを指定できます。
| ||||||||||||
| dwIndex | DWORD | in | 取得するパッチのインデックスです。このパラメーターは、MsiEnumPatchesEx 関数への最初の呼び出しではゼロでなければならず、その後の呼び出しでは増加させます。dwIndex パラメーターは、前回の呼び出しが ERROR_SUCCESS を返した場合にのみ増加させてください。 | ||||||||||||
| szPatchCode | LPSTR | outoptional | 列挙されるパッチの GUID を格納する出力バッファーです。バッファーは GUID を保持できる十分な大きさである必要があります。このパラメーターには NULL を指定できます。 | ||||||||||||
| szTargetProductCode | LPSTR | outoptional | このパッチを受け取る製品の ProductCode GUID を格納する出力バッファーです。バッファーは GUID を保持できる十分な大きさである必要があります。このパラメーターには NULL を指定できます。 | ||||||||||||
| pdwTargetProductContext | MSIINSTALLCONTEXT* | outoptional | 列挙されるパッチのコンテキストを返します。出力値は MSIINSTALLCONTEXT_USERMANAGED、MSIINSTALLCONTEXT_USERUNMANAGED、または MSIINSTALLCONTEXT_MACHINE のいずれかになります。このパラメーターには NULL を指定できます。 | ||||||||||||
| szTargetUserSid | LPSTR | outoptional | このパッチインスタンスが存在するアカウントの SID 文字列を受け取る出力バッファーです。コンピューター単位のコンテキストの場合、このバッファーには空文字列が返されます。 このバッファーは SID を格納できる十分な大きさである必要があります。バッファーが小さすぎる場合、関数は ERROR_MORE_DATA を返し、*pcchTargetUserSid に終端の NULL 文字を含まない値の TCHAR 数を設定します。 szTargetUserSid が NULL に設定され、pcchTargetUserSid が有効なポインターに設定されている場合、関数は ERROR_SUCCESS を返し、pcchTargetUserSid に終端の NULL 文字を含まない値の TCHAR 数を設定します。その後、pcchTargetUserSid + 1 文字を格納できる十分な大きさの szTargetUserSid バッファーを指定して関数を再度呼び出し、値を取得できます。 szTargetUserSid と pcchTargetUserSid の両方が NULL に設定されている場合、値が存在すれば関数は値を取得せずに ERROR_SUCCESS を返します。 | ||||||||||||
| pcchTargetUserSid | DWORD* | inoutoptional | szTargetUserSid バッファー内の TCHAR 数を指定する変数へのポインターです。関数が返るとき、このパラメーターには、関数が値を指定されたバッファーにコピーするかどうかにかかわらず、要求された値のサイズが設定されます。サイズは、終端の null 文字を含まない、要求された値の TCHAR 数として返されます。 このパラメーターを NULL に設定できるのは、szTargetUserSid も NULL の場合のみです。それ以外の場合、関数は ERROR_INVALID_PARAMETER を返します。 |
戻り値の型: DWORD
公式ドキュメント
特定のコンテキスト内、またはすべてのコンテキストにわたって、すべてのパッチを列挙します。(ANSI)
戻り値
MsiEnumPatchesEx 関数は、次のいずれかの値を返します。
| リターンコード | 説明 |
|---|---|
| 権限が不足しているリソースへのアクセスを試みて、関数が失敗しました。 | |
| 構成データが破損しています。 | |
| 無効なパラメーターが関数に渡されました。 | |
| 列挙するパッチがこれ以上ありません。 | |
| パッチが正常に列挙されました。 | |
| szProduct が指定する製品が、指定されたコンテキストでコンピューターにインストールされていません。 | |
| これは、pcchTargetUserSid が指すバッファーサイズが SID をコピーするのに必要なサイズより小さい場合に返されます。この場合、ユーザーはバッファーを修正し、同じインデックス値に対して MsiEnumPatchesEx を再度呼び出すことができます。 |
解説(Remarks)
管理者以外のユーザーは、自身が参照可能な範囲内でのみパッチを列挙できます。管理者は、他のユーザーコンテキストのパッチを列挙できます。
msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiEnumPatchesEx を定義します。エンコード非依存のエイリアスの使用を、エンコード非依存でないコードと混在させると、コンパイルエラーまたは実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、「Conventions for Function Prototypes」を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiEnumPatchesExA(
LPCSTR szProductCode, // optional
LPCSTR szUserSid, // optional
DWORD dwContext,
DWORD dwFilter,
DWORD dwIndex,
LPSTR szPatchCode, // optional
LPSTR szTargetProductCode, // optional
MSIINSTALLCONTEXT* pdwTargetProductContext, // optional
LPSTR szTargetUserSid, // optional
DWORD* pcchTargetUserSid // optional
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiEnumPatchesExA(
[MarshalAs(UnmanagedType.LPStr)] string szProductCode, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string szUserSid, // LPCSTR optional
uint dwContext, // DWORD
uint dwFilter, // DWORD
uint dwIndex, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szPatchCode, // LPSTR optional, out
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szTargetProductCode, // LPSTR optional, out
IntPtr pdwTargetProductContext, // MSIINSTALLCONTEXT* optional, out
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szTargetUserSid, // LPSTR optional, out
IntPtr pcchTargetUserSid // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiEnumPatchesExA(
<MarshalAs(UnmanagedType.LPStr)> szProductCode As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> szUserSid As String, ' LPCSTR optional
dwContext As UInteger, ' DWORD
dwFilter As UInteger, ' DWORD
dwIndex As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> szPatchCode As System.Text.StringBuilder, ' LPSTR optional, out
<MarshalAs(UnmanagedType.LPStr)> szTargetProductCode As System.Text.StringBuilder, ' LPSTR optional, out
pdwTargetProductContext As IntPtr, ' MSIINSTALLCONTEXT* optional, out
<MarshalAs(UnmanagedType.LPStr)> szTargetUserSid As System.Text.StringBuilder, ' LPSTR optional, out
pcchTargetUserSid As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' szProductCode : LPCSTR optional
' szUserSid : LPCSTR optional
' dwContext : DWORD
' dwFilter : DWORD
' dwIndex : DWORD
' szPatchCode : LPSTR optional, out
' szTargetProductCode : LPSTR optional, out
' pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
' szTargetUserSid : LPSTR optional, out
' pcchTargetUserSid : DWORD* optional, in/out
Declare PtrSafe Function MsiEnumPatchesExA Lib "msi" ( _
ByVal szProductCode As String, _
ByVal szUserSid As String, _
ByVal dwContext As Long, _
ByVal dwFilter As Long, _
ByVal dwIndex As Long, _
ByVal szPatchCode As String, _
ByVal szTargetProductCode As String, _
ByVal pdwTargetProductContext As LongPtr, _
ByVal szTargetUserSid As String, _
ByVal pcchTargetUserSid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiEnumPatchesExA = ctypes.windll.msi.MsiEnumPatchesExA
MsiEnumPatchesExA.restype = wintypes.DWORD
MsiEnumPatchesExA.argtypes = [
wintypes.LPCSTR, # szProductCode : LPCSTR optional
wintypes.LPCSTR, # szUserSid : LPCSTR optional
wintypes.DWORD, # dwContext : DWORD
wintypes.DWORD, # dwFilter : DWORD
wintypes.DWORD, # dwIndex : DWORD
wintypes.LPSTR, # szPatchCode : LPSTR optional, out
wintypes.LPSTR, # szTargetProductCode : LPSTR optional, out
ctypes.c_void_p, # pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
wintypes.LPSTR, # szTargetUserSid : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchTargetUserSid : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiEnumPatchesExA = Fiddle::Function.new(
lib['MsiEnumPatchesExA'],
[
Fiddle::TYPE_VOIDP, # szProductCode : LPCSTR optional
Fiddle::TYPE_VOIDP, # szUserSid : LPCSTR optional
-Fiddle::TYPE_INT, # dwContext : DWORD
-Fiddle::TYPE_INT, # dwFilter : DWORD
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_VOIDP, # szPatchCode : LPSTR optional, out
Fiddle::TYPE_VOIDP, # szTargetProductCode : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
Fiddle::TYPE_VOIDP, # szTargetUserSid : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchTargetUserSid : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiEnumPatchesExA(
szProductCode: *const u8, // LPCSTR optional
szUserSid: *const u8, // LPCSTR optional
dwContext: u32, // DWORD
dwFilter: u32, // DWORD
dwIndex: u32, // DWORD
szPatchCode: *mut u8, // LPSTR optional, out
szTargetProductCode: *mut u8, // LPSTR optional, out
pdwTargetProductContext: *mut i32, // MSIINSTALLCONTEXT* optional, out
szTargetUserSid: *mut u8, // LPSTR optional, out
pcchTargetUserSid: *mut u32 // DWORD* optional, in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiEnumPatchesExA([MarshalAs(UnmanagedType.LPStr)] string szProductCode, [MarshalAs(UnmanagedType.LPStr)] string szUserSid, uint dwContext, uint dwFilter, uint dwIndex, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szPatchCode, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szTargetProductCode, IntPtr pdwTargetProductContext, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szTargetUserSid, IntPtr pcchTargetUserSid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiEnumPatchesExA' -Namespace Win32 -PassThru
# $api::MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)#uselib "msi.dll"
#func global MsiEnumPatchesExA "MsiEnumPatchesExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MsiEnumPatchesExA szProductCode, szUserSid, dwContext, dwFilter, dwIndex, varptr(szPatchCode), varptr(szTargetProductCode), varptr(pdwTargetProductContext), varptr(szTargetUserSid), varptr(pcchTargetUserSid) ; 戻り値は stat
; szProductCode : LPCSTR optional -> "sptr"
; szUserSid : LPCSTR optional -> "sptr"
; dwContext : DWORD -> "sptr"
; dwFilter : DWORD -> "sptr"
; dwIndex : DWORD -> "sptr"
; szPatchCode : LPSTR optional, out -> "sptr"
; szTargetProductCode : LPSTR optional, out -> "sptr"
; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "sptr"
; szTargetUserSid : LPSTR optional, out -> "sptr"
; pcchTargetUserSid : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll" #cfunc global MsiEnumPatchesExA "MsiEnumPatchesExA" str, str, int, int, int, var, var, var, var, var ; res = MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid) ; szProductCode : LPCSTR optional -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : DWORD -> "int" ; dwFilter : DWORD -> "int" ; dwIndex : DWORD -> "int" ; szPatchCode : LPSTR optional, out -> "var" ; szTargetProductCode : LPSTR optional, out -> "var" ; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "var" ; szTargetUserSid : LPSTR optional, out -> "var" ; pcchTargetUserSid : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiEnumPatchesExA "MsiEnumPatchesExA" str, str, int, int, int, sptr, sptr, sptr, sptr, sptr ; res = MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, varptr(szPatchCode), varptr(szTargetProductCode), varptr(pdwTargetProductContext), varptr(szTargetUserSid), varptr(pcchTargetUserSid)) ; szProductCode : LPCSTR optional -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : DWORD -> "int" ; dwFilter : DWORD -> "int" ; dwIndex : DWORD -> "int" ; szPatchCode : LPSTR optional, out -> "sptr" ; szTargetProductCode : LPSTR optional, out -> "sptr" ; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "sptr" ; szTargetUserSid : LPSTR optional, out -> "sptr" ; pcchTargetUserSid : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; DWORD MsiEnumPatchesExA(LPCSTR szProductCode, LPCSTR szUserSid, DWORD dwContext, DWORD dwFilter, DWORD dwIndex, LPSTR szPatchCode, LPSTR szTargetProductCode, MSIINSTALLCONTEXT* pdwTargetProductContext, LPSTR szTargetUserSid, DWORD* pcchTargetUserSid) #uselib "msi.dll" #cfunc global MsiEnumPatchesExA "MsiEnumPatchesExA" str, str, int, int, int, var, var, var, var, var ; res = MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid) ; szProductCode : LPCSTR optional -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : DWORD -> "int" ; dwFilter : DWORD -> "int" ; dwIndex : DWORD -> "int" ; szPatchCode : LPSTR optional, out -> "var" ; szTargetProductCode : LPSTR optional, out -> "var" ; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "var" ; szTargetUserSid : LPSTR optional, out -> "var" ; pcchTargetUserSid : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiEnumPatchesExA(LPCSTR szProductCode, LPCSTR szUserSid, DWORD dwContext, DWORD dwFilter, DWORD dwIndex, LPSTR szPatchCode, LPSTR szTargetProductCode, MSIINSTALLCONTEXT* pdwTargetProductContext, LPSTR szTargetUserSid, DWORD* pcchTargetUserSid) #uselib "msi.dll" #cfunc global MsiEnumPatchesExA "MsiEnumPatchesExA" str, str, int, int, int, intptr, intptr, intptr, intptr, intptr ; res = MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, varptr(szPatchCode), varptr(szTargetProductCode), varptr(pdwTargetProductContext), varptr(szTargetUserSid), varptr(pcchTargetUserSid)) ; szProductCode : LPCSTR optional -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : DWORD -> "int" ; dwFilter : DWORD -> "int" ; dwIndex : DWORD -> "int" ; szPatchCode : LPSTR optional, out -> "intptr" ; szTargetProductCode : LPSTR optional, out -> "intptr" ; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "intptr" ; szTargetUserSid : LPSTR optional, out -> "intptr" ; pcchTargetUserSid : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiEnumPatchesExA = msi.NewProc("MsiEnumPatchesExA")
)
// szProductCode (LPCSTR optional), szUserSid (LPCSTR optional), dwContext (DWORD), dwFilter (DWORD), dwIndex (DWORD), szPatchCode (LPSTR optional, out), szTargetProductCode (LPSTR optional, out), pdwTargetProductContext (MSIINSTALLCONTEXT* optional, out), szTargetUserSid (LPSTR optional, out), pcchTargetUserSid (DWORD* optional, in/out)
r1, _, err := procMsiEnumPatchesExA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProductCode))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szUserSid))),
uintptr(dwContext),
uintptr(dwFilter),
uintptr(dwIndex),
uintptr(szPatchCode),
uintptr(szTargetProductCode),
uintptr(pdwTargetProductContext),
uintptr(szTargetUserSid),
uintptr(pcchTargetUserSid),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiEnumPatchesExA(
szProductCode: PAnsiChar; // LPCSTR optional
szUserSid: PAnsiChar; // LPCSTR optional
dwContext: DWORD; // DWORD
dwFilter: DWORD; // DWORD
dwIndex: DWORD; // DWORD
szPatchCode: PAnsiChar; // LPSTR optional, out
szTargetProductCode: PAnsiChar; // LPSTR optional, out
pdwTargetProductContext: Pointer; // MSIINSTALLCONTEXT* optional, out
szTargetUserSid: PAnsiChar; // LPSTR optional, out
pcchTargetUserSid: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiEnumPatchesExA';result := DllCall("msi\MsiEnumPatchesExA"
, "AStr", szProductCode ; LPCSTR optional
, "AStr", szUserSid ; LPCSTR optional
, "UInt", dwContext ; DWORD
, "UInt", dwFilter ; DWORD
, "UInt", dwIndex ; DWORD
, "Ptr", szPatchCode ; LPSTR optional, out
, "Ptr", szTargetProductCode ; LPSTR optional, out
, "Ptr", pdwTargetProductContext ; MSIINSTALLCONTEXT* optional, out
, "Ptr", szTargetUserSid ; LPSTR optional, out
, "Ptr", pcchTargetUserSid ; DWORD* optional, in/out
, "UInt") ; return: DWORD●MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid) = DLL("msi.dll", "dword MsiEnumPatchesExA(char*, char*, dword, dword, dword, char*, char*, void*, char*, void*)")
# 呼び出し: MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
# szProductCode : LPCSTR optional -> "char*"
# szUserSid : LPCSTR optional -> "char*"
# dwContext : DWORD -> "dword"
# dwFilter : DWORD -> "dword"
# dwIndex : DWORD -> "dword"
# szPatchCode : LPSTR optional, out -> "char*"
# szTargetProductCode : LPSTR optional, out -> "char*"
# pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "void*"
# szTargetUserSid : LPSTR optional, out -> "char*"
# pcchTargetUserSid : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiEnumPatchesExA(
szProductCode: [*c]const u8, // LPCSTR optional
szUserSid: [*c]const u8, // LPCSTR optional
dwContext: u32, // DWORD
dwFilter: u32, // DWORD
dwIndex: u32, // DWORD
szPatchCode: [*c]u8, // LPSTR optional, out
szTargetProductCode: [*c]u8, // LPSTR optional, out
pdwTargetProductContext: [*c]i32, // MSIINSTALLCONTEXT* optional, out
szTargetUserSid: [*c]u8, // LPSTR optional, out
pcchTargetUserSid: [*c]u32 // DWORD* optional, in/out
) callconv(std.os.windows.WINAPI) u32;proc MsiEnumPatchesExA(
szProductCode: cstring, # LPCSTR optional
szUserSid: cstring, # LPCSTR optional
dwContext: uint32, # DWORD
dwFilter: uint32, # DWORD
dwIndex: uint32, # DWORD
szPatchCode: ptr char, # LPSTR optional, out
szTargetProductCode: ptr char, # LPSTR optional, out
pdwTargetProductContext: ptr int32, # MSIINSTALLCONTEXT* optional, out
szTargetUserSid: ptr char, # LPSTR optional, out
pcchTargetUserSid: ptr uint32 # DWORD* optional, in/out
): uint32 {.importc: "MsiEnumPatchesExA", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiEnumPatchesExA(
const(char)* szProductCode, // LPCSTR optional
const(char)* szUserSid, // LPCSTR optional
uint dwContext, // DWORD
uint dwFilter, // DWORD
uint dwIndex, // DWORD
char* szPatchCode, // LPSTR optional, out
char* szTargetProductCode, // LPSTR optional, out
int* pdwTargetProductContext, // MSIINSTALLCONTEXT* optional, out
char* szTargetUserSid, // LPSTR optional, out
uint* pcchTargetUserSid // DWORD* optional, in/out
);ccall((:MsiEnumPatchesExA, "msi.dll"), stdcall, UInt32,
(Cstring, Cstring, UInt32, UInt32, UInt32, Ptr{UInt8}, Ptr{UInt8}, Ptr{Int32}, Ptr{UInt8}, Ptr{UInt32}),
szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
# szProductCode : LPCSTR optional -> Cstring
# szUserSid : LPCSTR optional -> Cstring
# dwContext : DWORD -> UInt32
# dwFilter : DWORD -> UInt32
# dwIndex : DWORD -> UInt32
# szPatchCode : LPSTR optional, out -> Ptr{UInt8}
# szTargetProductCode : LPSTR optional, out -> Ptr{UInt8}
# pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> Ptr{Int32}
# szTargetUserSid : LPSTR optional, out -> Ptr{UInt8}
# pcchTargetUserSid : DWORD* optional, in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiEnumPatchesExA(
const char* szProductCode,
const char* szUserSid,
uint32_t dwContext,
uint32_t dwFilter,
uint32_t dwIndex,
char* szPatchCode,
char* szTargetProductCode,
int32_t* pdwTargetProductContext,
char* szTargetUserSid,
uint32_t* pcchTargetUserSid);
]]
local msi = ffi.load("msi")
-- msi.MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
-- szProductCode : LPCSTR optional
-- szUserSid : LPCSTR optional
-- dwContext : DWORD
-- dwFilter : DWORD
-- dwIndex : DWORD
-- szPatchCode : LPSTR optional, out
-- szTargetProductCode : LPSTR optional, out
-- pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
-- szTargetUserSid : LPSTR optional, out
-- pcchTargetUserSid : DWORD* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiEnumPatchesExA = lib.func('__stdcall', 'MsiEnumPatchesExA', 'uint32_t', ['str', 'str', 'uint32_t', 'uint32_t', 'uint32_t', 'char *', 'char *', 'int32_t *', 'char *', 'uint32_t *']);
// MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
// szProductCode : LPCSTR optional -> 'str'
// szUserSid : LPCSTR optional -> 'str'
// dwContext : DWORD -> 'uint32_t'
// dwFilter : DWORD -> 'uint32_t'
// dwIndex : DWORD -> 'uint32_t'
// szPatchCode : LPSTR optional, out -> 'char *'
// szTargetProductCode : LPSTR optional, out -> 'char *'
// pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> 'int32_t *'
// szTargetUserSid : LPSTR optional, out -> 'char *'
// pcchTargetUserSid : DWORD* optional, in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiEnumPatchesExA: { parameters: ["buffer", "buffer", "u32", "u32", "u32", "buffer", "buffer", "pointer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
// szProductCode : LPCSTR optional -> "buffer"
// szUserSid : LPCSTR optional -> "buffer"
// dwContext : DWORD -> "u32"
// dwFilter : DWORD -> "u32"
// dwIndex : DWORD -> "u32"
// szPatchCode : LPSTR optional, out -> "buffer"
// szTargetProductCode : LPSTR optional, out -> "buffer"
// pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "pointer"
// szTargetUserSid : LPSTR optional, out -> "buffer"
// pcchTargetUserSid : DWORD* optional, in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiEnumPatchesExA(
const char* szProductCode,
const char* szUserSid,
uint32_t dwContext,
uint32_t dwFilter,
uint32_t dwIndex,
char* szPatchCode,
char* szTargetProductCode,
int32_t* pdwTargetProductContext,
char* szTargetUserSid,
uint32_t* pcchTargetUserSid);
C, "msi.dll");
// $ffi->MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid);
// szProductCode : LPCSTR optional
// szUserSid : LPCSTR optional
// dwContext : DWORD
// dwFilter : DWORD
// dwIndex : DWORD
// szPatchCode : LPSTR optional, out
// szTargetProductCode : LPSTR optional, out
// pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
// szTargetUserSid : LPSTR optional, out
// pcchTargetUserSid : DWORD* optional, in/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 MsiEnumPatchesExA(
String szProductCode, // LPCSTR optional
String szUserSid, // LPCSTR optional
int dwContext, // DWORD
int dwFilter, // DWORD
int dwIndex, // DWORD
byte[] szPatchCode, // LPSTR optional, out
byte[] szTargetProductCode, // LPSTR optional, out
IntByReference pdwTargetProductContext, // MSIINSTALLCONTEXT* optional, out
byte[] szTargetUserSid, // LPSTR optional, out
IntByReference pcchTargetUserSid // DWORD* optional, in/out
);
}@[Link("msi")]
lib Libmsi
fun MsiEnumPatchesExA = MsiEnumPatchesExA(
szProductCode : UInt8*, # LPCSTR optional
szUserSid : UInt8*, # LPCSTR optional
dwContext : UInt32, # DWORD
dwFilter : UInt32, # DWORD
dwIndex : UInt32, # DWORD
szPatchCode : UInt8*, # LPSTR optional, out
szTargetProductCode : UInt8*, # LPSTR optional, out
pdwTargetProductContext : Int32*, # MSIINSTALLCONTEXT* optional, out
szTargetUserSid : UInt8*, # LPSTR optional, out
pcchTargetUserSid : UInt32* # DWORD* optional, in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiEnumPatchesExANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Uint32, Uint32, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Int32>, Pointer<Utf8>, Pointer<Uint32>);
typedef MsiEnumPatchesExADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int, int, int, Pointer<Utf8>, Pointer<Utf8>, Pointer<Int32>, Pointer<Utf8>, Pointer<Uint32>);
final MsiEnumPatchesExA = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiEnumPatchesExANative, MsiEnumPatchesExADart>('MsiEnumPatchesExA');
// szProductCode : LPCSTR optional -> Pointer<Utf8>
// szUserSid : LPCSTR optional -> Pointer<Utf8>
// dwContext : DWORD -> Uint32
// dwFilter : DWORD -> Uint32
// dwIndex : DWORD -> Uint32
// szPatchCode : LPSTR optional, out -> Pointer<Utf8>
// szTargetProductCode : LPSTR optional, out -> Pointer<Utf8>
// pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> Pointer<Int32>
// szTargetUserSid : LPSTR optional, out -> Pointer<Utf8>
// pcchTargetUserSid : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiEnumPatchesExA(
szProductCode: PAnsiChar; // LPCSTR optional
szUserSid: PAnsiChar; // LPCSTR optional
dwContext: DWORD; // DWORD
dwFilter: DWORD; // DWORD
dwIndex: DWORD; // DWORD
szPatchCode: PAnsiChar; // LPSTR optional, out
szTargetProductCode: PAnsiChar; // LPSTR optional, out
pdwTargetProductContext: Pointer; // MSIINSTALLCONTEXT* optional, out
szTargetUserSid: PAnsiChar; // LPSTR optional, out
pcchTargetUserSid: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiEnumPatchesExA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiEnumPatchesExA"
c_MsiEnumPatchesExA :: CString -> CString -> Word32 -> Word32 -> Word32 -> CString -> CString -> Ptr Int32 -> CString -> Ptr Word32 -> IO Word32
-- szProductCode : LPCSTR optional -> CString
-- szUserSid : LPCSTR optional -> CString
-- dwContext : DWORD -> Word32
-- dwFilter : DWORD -> Word32
-- dwIndex : DWORD -> Word32
-- szPatchCode : LPSTR optional, out -> CString
-- szTargetProductCode : LPSTR optional, out -> CString
-- pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> Ptr Int32
-- szTargetUserSid : LPSTR optional, out -> CString
-- pcchTargetUserSid : DWORD* optional, in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msienumpatchesexa =
foreign "MsiEnumPatchesExA"
(string @-> string @-> uint32_t @-> uint32_t @-> uint32_t @-> string @-> string @-> (ptr int32_t) @-> string @-> (ptr uint32_t) @-> returning uint32_t)
(* szProductCode : LPCSTR optional -> string *)
(* szUserSid : LPCSTR optional -> string *)
(* dwContext : DWORD -> uint32_t *)
(* dwFilter : DWORD -> uint32_t *)
(* dwIndex : DWORD -> uint32_t *)
(* szPatchCode : LPSTR optional, out -> string *)
(* szTargetProductCode : LPSTR optional, out -> string *)
(* pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> (ptr int32_t) *)
(* szTargetUserSid : LPSTR optional, out -> string *)
(* pcchTargetUserSid : DWORD* optional, in/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 ("MsiEnumPatchesExA" msi-enum-patches-ex-a :convention :stdcall) :uint32
(sz-product-code :string) ; LPCSTR optional
(sz-user-sid :string) ; LPCSTR optional
(dw-context :uint32) ; DWORD
(dw-filter :uint32) ; DWORD
(dw-index :uint32) ; DWORD
(sz-patch-code :pointer) ; LPSTR optional, out
(sz-target-product-code :pointer) ; LPSTR optional, out
(pdw-target-product-context :pointer) ; MSIINSTALLCONTEXT* optional, out
(sz-target-user-sid :pointer) ; LPSTR optional, out
(pcch-target-user-sid :pointer)) ; DWORD* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiEnumPatchesExA = Win32::API::More->new('msi',
'DWORD MsiEnumPatchesExA(LPCSTR szProductCode, LPCSTR szUserSid, DWORD dwContext, DWORD dwFilter, DWORD dwIndex, LPSTR szPatchCode, LPSTR szTargetProductCode, LPVOID pdwTargetProductContext, LPSTR szTargetUserSid, LPVOID pcchTargetUserSid)');
# my $ret = $MsiEnumPatchesExA->Call($szProductCode, $szUserSid, $dwContext, $dwFilter, $dwIndex, $szPatchCode, $szTargetProductCode, $pdwTargetProductContext, $szTargetUserSid, $pcchTargetUserSid);
# szProductCode : LPCSTR optional -> LPCSTR
# szUserSid : LPCSTR optional -> LPCSTR
# dwContext : DWORD -> DWORD
# dwFilter : DWORD -> DWORD
# dwIndex : DWORD -> DWORD
# szPatchCode : LPSTR optional, out -> LPSTR
# szTargetProductCode : LPSTR optional, out -> LPSTR
# pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> LPVOID
# szTargetUserSid : LPSTR optional, out -> LPSTR
# pcchTargetUserSid : DWORD* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f MsiEnumPatchesExW (Unicode版) — コンテキストやフィルタを指定してパッチを列挙する(Unicode版)。
- f MsiEnumPatchesA — 製品に適用されたパッチを列挙する(ANSI版)。
- f MsiSourceListAddSourceExA — コンテキストや種別を指定して製品やパッチのソースを追加する。