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

MsiEnumPatchesExW

関数
コンテキストやフィルタを指定してパッチを列挙する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiEnumPatchesExW(
    LPCWSTR szProductCode,   // optional
    LPCWSTR szUserSid,   // optional
    DWORD dwContext,
    DWORD dwFilter,
    DWORD dwIndex,
    LPWSTR szPatchCode,   // optional
    LPWSTR szTargetProductCode,   // optional
    MSIINSTALLCONTEXT* pdwTargetProductContext,   // optional
    LPWSTR szTargetUserSid,   // optional
    DWORD* pcchTargetUserSid   // optional
);

パラメーター

名前方向
szProductCodeLPCWSTRinoptional
szUserSidLPCWSTRinoptional
dwContextDWORDin
dwFilterDWORDin
dwIndexDWORDin
szPatchCodeLPWSTRoutoptional
szTargetProductCodeLPWSTRoutoptional
pdwTargetProductContextMSIINSTALLCONTEXT*outoptional
szTargetUserSidLPWSTRoutoptional
pcchTargetUserSidDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiEnumPatchesExW(
    LPCWSTR szProductCode,   // optional
    LPCWSTR szUserSid,   // optional
    DWORD dwContext,
    DWORD dwFilter,
    DWORD dwIndex,
    LPWSTR szPatchCode,   // optional
    LPWSTR szTargetProductCode,   // optional
    MSIINSTALLCONTEXT* pdwTargetProductContext,   // optional
    LPWSTR szTargetUserSid,   // optional
    DWORD* pcchTargetUserSid   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiEnumPatchesExW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProductCode,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string szUserSid,   // LPCWSTR optional
    uint dwContext,   // DWORD
    uint dwFilter,   // DWORD
    uint dwIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szPatchCode,   // LPWSTR optional, out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szTargetProductCode,   // LPWSTR optional, out
    IntPtr pdwTargetProductContext,   // MSIINSTALLCONTEXT* optional, out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szTargetUserSid,   // LPWSTR optional, out
    IntPtr pcchTargetUserSid   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiEnumPatchesExW(
    <MarshalAs(UnmanagedType.LPWStr)> szProductCode As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> szUserSid As String,   ' LPCWSTR optional
    dwContext As UInteger,   ' DWORD
    dwFilter As UInteger,   ' DWORD
    dwIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> szPatchCode As System.Text.StringBuilder,   ' LPWSTR optional, out
    <MarshalAs(UnmanagedType.LPWStr)> szTargetProductCode As System.Text.StringBuilder,   ' LPWSTR optional, out
    pdwTargetProductContext As IntPtr,   ' MSIINSTALLCONTEXT* optional, out
    <MarshalAs(UnmanagedType.LPWStr)> szTargetUserSid As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcchTargetUserSid As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' szProductCode : LPCWSTR optional
' szUserSid : LPCWSTR optional
' dwContext : DWORD
' dwFilter : DWORD
' dwIndex : DWORD
' szPatchCode : LPWSTR optional, out
' szTargetProductCode : LPWSTR optional, out
' pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
' szTargetUserSid : LPWSTR optional, out
' pcchTargetUserSid : DWORD* optional, in/out
Declare PtrSafe Function MsiEnumPatchesExW Lib "msi" ( _
    ByVal szProductCode As LongPtr, _
    ByVal szUserSid As LongPtr, _
    ByVal dwContext As Long, _
    ByVal dwFilter As Long, _
    ByVal dwIndex As Long, _
    ByVal szPatchCode As LongPtr, _
    ByVal szTargetProductCode As LongPtr, _
    ByVal pdwTargetProductContext As LongPtr, _
    ByVal szTargetUserSid As LongPtr, _
    ByVal pcchTargetUserSid 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

MsiEnumPatchesExW = ctypes.windll.msi.MsiEnumPatchesExW
MsiEnumPatchesExW.restype = wintypes.DWORD
MsiEnumPatchesExW.argtypes = [
    wintypes.LPCWSTR,  # szProductCode : LPCWSTR optional
    wintypes.LPCWSTR,  # szUserSid : LPCWSTR optional
    wintypes.DWORD,  # dwContext : DWORD
    wintypes.DWORD,  # dwFilter : DWORD
    wintypes.DWORD,  # dwIndex : DWORD
    wintypes.LPWSTR,  # szPatchCode : LPWSTR optional, out
    wintypes.LPWSTR,  # szTargetProductCode : LPWSTR optional, out
    ctypes.c_void_p,  # pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
    wintypes.LPWSTR,  # szTargetUserSid : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchTargetUserSid : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiEnumPatchesExW = Fiddle::Function.new(
  lib['MsiEnumPatchesExW'],
  [
    Fiddle::TYPE_VOIDP,  # szProductCode : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # szUserSid : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwContext : DWORD
    -Fiddle::TYPE_INT,  # dwFilter : DWORD
    -Fiddle::TYPE_INT,  # dwIndex : DWORD
    Fiddle::TYPE_VOIDP,  # szPatchCode : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # szTargetProductCode : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out
    Fiddle::TYPE_VOIDP,  # szTargetUserSid : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchTargetUserSid : DWORD* optional, in/out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiEnumPatchesExW(
        szProductCode: *const u16,  // LPCWSTR optional
        szUserSid: *const u16,  // LPCWSTR optional
        dwContext: u32,  // DWORD
        dwFilter: u32,  // DWORD
        dwIndex: u32,  // DWORD
        szPatchCode: *mut u16,  // LPWSTR optional, out
        szTargetProductCode: *mut u16,  // LPWSTR optional, out
        pdwTargetProductContext: *mut i32,  // MSIINSTALLCONTEXT* optional, out
        szTargetUserSid: *mut u16,  // LPWSTR 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.Unicode)]
public static extern uint MsiEnumPatchesExW([MarshalAs(UnmanagedType.LPWStr)] string szProductCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, uint dwContext, uint dwFilter, uint dwIndex, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szPatchCode, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szTargetProductCode, IntPtr pdwTargetProductContext, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szTargetUserSid, IntPtr pcchTargetUserSid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiEnumPatchesExW' -Namespace Win32 -PassThru
# $api::MsiEnumPatchesExW(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
#uselib "msi.dll"
#func global MsiEnumPatchesExW "MsiEnumPatchesExW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; MsiEnumPatchesExW szProductCode, szUserSid, dwContext, dwFilter, dwIndex, varptr(szPatchCode), varptr(szTargetProductCode), pdwTargetProductContext, varptr(szTargetUserSid), varptr(pcchTargetUserSid)   ; 戻り値は stat
; szProductCode : LPCWSTR optional -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : DWORD -> "wptr"
; dwFilter : DWORD -> "wptr"
; dwIndex : DWORD -> "wptr"
; szPatchCode : LPWSTR optional, out -> "wptr"
; szTargetProductCode : LPWSTR optional, out -> "wptr"
; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "wptr"
; szTargetUserSid : LPWSTR optional, out -> "wptr"
; pcchTargetUserSid : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiEnumPatchesExW "MsiEnumPatchesExW" wstr, wstr, int, int, int, var, var, int, var, var
; res = MsiEnumPatchesExW(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
; szProductCode : LPCWSTR optional -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : DWORD -> "int"
; dwFilter : DWORD -> "int"
; dwIndex : DWORD -> "int"
; szPatchCode : LPWSTR optional, out -> "var"
; szTargetProductCode : LPWSTR optional, out -> "var"
; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "int"
; szTargetUserSid : LPWSTR optional, out -> "var"
; pcchTargetUserSid : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiEnumPatchesExW(LPCWSTR szProductCode, LPCWSTR szUserSid, DWORD dwContext, DWORD dwFilter, DWORD dwIndex, LPWSTR szPatchCode, LPWSTR szTargetProductCode, MSIINSTALLCONTEXT* pdwTargetProductContext, LPWSTR szTargetUserSid, DWORD* pcchTargetUserSid)
#uselib "msi.dll"
#cfunc global MsiEnumPatchesExW "MsiEnumPatchesExW" wstr, wstr, int, int, int, var, var, int, var, var
; res = MsiEnumPatchesExW(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
; szProductCode : LPCWSTR optional -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : DWORD -> "int"
; dwFilter : DWORD -> "int"
; dwIndex : DWORD -> "int"
; szPatchCode : LPWSTR optional, out -> "var"
; szTargetProductCode : LPWSTR optional, out -> "var"
; pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "int"
; szTargetUserSid : LPWSTR optional, out -> "var"
; pcchTargetUserSid : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiEnumPatchesExW = msi.NewProc("MsiEnumPatchesExW")
)

// szProductCode (LPCWSTR optional), szUserSid (LPCWSTR optional), dwContext (DWORD), dwFilter (DWORD), dwIndex (DWORD), szPatchCode (LPWSTR optional, out), szTargetProductCode (LPWSTR optional, out), pdwTargetProductContext (MSIINSTALLCONTEXT* optional, out), szTargetUserSid (LPWSTR optional, out), pcchTargetUserSid (DWORD* optional, in/out)
r1, _, err := procMsiEnumPatchesExW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCode))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(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   // DWORD
function MsiEnumPatchesExW(
  szProductCode: PWideChar;   // LPCWSTR optional
  szUserSid: PWideChar;   // LPCWSTR optional
  dwContext: DWORD;   // DWORD
  dwFilter: DWORD;   // DWORD
  dwIndex: DWORD;   // DWORD
  szPatchCode: PWideChar;   // LPWSTR optional, out
  szTargetProductCode: PWideChar;   // LPWSTR optional, out
  pdwTargetProductContext: Pointer;   // MSIINSTALLCONTEXT* optional, out
  szTargetUserSid: PWideChar;   // LPWSTR optional, out
  pcchTargetUserSid: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiEnumPatchesExW';
result := DllCall("msi\MsiEnumPatchesExW"
    , "WStr", szProductCode   ; LPCWSTR optional
    , "WStr", szUserSid   ; LPCWSTR optional
    , "UInt", dwContext   ; DWORD
    , "UInt", dwFilter   ; DWORD
    , "UInt", dwIndex   ; DWORD
    , "Ptr", szPatchCode   ; LPWSTR optional, out
    , "Ptr", szTargetProductCode   ; LPWSTR optional, out
    , "Ptr", pdwTargetProductContext   ; MSIINSTALLCONTEXT* optional, out
    , "Ptr", szTargetUserSid   ; LPWSTR optional, out
    , "Ptr", pcchTargetUserSid   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiEnumPatchesExW(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid) = DLL("msi.dll", "dword MsiEnumPatchesExW(char*, char*, dword, dword, dword, char*, char*, void*, char*, void*)")
# 呼び出し: MsiEnumPatchesExW(szProductCode, szUserSid, dwContext, dwFilter, dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext, szTargetUserSid, pcchTargetUserSid)
# szProductCode : LPCWSTR optional -> "char*"
# szUserSid : LPCWSTR optional -> "char*"
# dwContext : DWORD -> "dword"
# dwFilter : DWORD -> "dword"
# dwIndex : DWORD -> "dword"
# szPatchCode : LPWSTR optional, out -> "char*"
# szTargetProductCode : LPWSTR optional, out -> "char*"
# pdwTargetProductContext : MSIINSTALLCONTEXT* optional, out -> "void*"
# szTargetUserSid : LPWSTR optional, out -> "char*"
# pcchTargetUserSid : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。