ホーム › System.ApplicationInstallationAndServicing › MsiEnumPatchesExA
MsiEnumPatchesExA
関数コンテキストやフィルタを指定してパッチを列挙する(ANSI版)。
シグネチャ
// 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 |
| szUserSid | LPCSTR | inoptional |
| dwContext | DWORD | in |
| dwFilter | DWORD | in |
| dwIndex | DWORD | in |
| szPatchCode | LPSTR | outoptional |
| szTargetProductCode | LPSTR | outoptional |
| pdwTargetProductContext | MSIINSTALLCONTEXT* | outoptional |
| szTargetUserSid | LPSTR | outoptional |
| pcchTargetUserSid | DWORD* | inoutoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// 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), 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, int, 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 -> "int" ; 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, int, sptr, sptr ; res = MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, varptr(szPatchCode), varptr(szTargetProductCode), 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 -> "int" ; 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, int, 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 -> "int" ; 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, int, intptr, intptr ; res = MsiEnumPatchesExA(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, varptr(szPatchCode), varptr(szTargetProductCode), 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 -> "int" ; 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)。