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

MsiEnumPatchesW

関数
製品に適用されたパッチを列挙する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiEnumPatchesW(
    LPCWSTR szProduct,
    DWORD iPatchIndex,
    LPWSTR lpPatchBuf,
    LPWSTR lpTransformsBuf,
    DWORD* pcchTransformsBuf
);

パラメーター

名前方向
szProductLPCWSTRin
iPatchIndexDWORDin
lpPatchBufLPWSTRout
lpTransformsBufLPWSTRout
pcchTransformsBufDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiEnumPatchesW(
    LPCWSTR szProduct,
    DWORD iPatchIndex,
    LPWSTR lpPatchBuf,
    LPWSTR lpTransformsBuf,
    DWORD* pcchTransformsBuf
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiEnumPatchesW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProduct,   // LPCWSTR
    uint iPatchIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPatchBuf,   // LPWSTR out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpTransformsBuf,   // LPWSTR out
    ref uint pcchTransformsBuf   // DWORD* in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiEnumPatchesW(
    <MarshalAs(UnmanagedType.LPWStr)> szProduct As String,   ' LPCWSTR
    iPatchIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpPatchBuf As System.Text.StringBuilder,   ' LPWSTR out
    <MarshalAs(UnmanagedType.LPWStr)> lpTransformsBuf As System.Text.StringBuilder,   ' LPWSTR out
    ByRef pcchTransformsBuf As UInteger   ' DWORD* in/out
) As UInteger
End Function
' szProduct : LPCWSTR
' iPatchIndex : DWORD
' lpPatchBuf : LPWSTR out
' lpTransformsBuf : LPWSTR out
' pcchTransformsBuf : DWORD* in/out
Declare PtrSafe Function MsiEnumPatchesW Lib "msi" ( _
    ByVal szProduct As LongPtr, _
    ByVal iPatchIndex As Long, _
    ByVal lpPatchBuf As LongPtr, _
    ByVal lpTransformsBuf As LongPtr, _
    ByRef pcchTransformsBuf As Long) 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

MsiEnumPatchesW = ctypes.windll.msi.MsiEnumPatchesW
MsiEnumPatchesW.restype = wintypes.DWORD
MsiEnumPatchesW.argtypes = [
    wintypes.LPCWSTR,  # szProduct : LPCWSTR
    wintypes.DWORD,  # iPatchIndex : DWORD
    wintypes.LPWSTR,  # lpPatchBuf : LPWSTR out
    wintypes.LPWSTR,  # lpTransformsBuf : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchTransformsBuf : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiEnumPatchesW = Fiddle::Function.new(
  lib['MsiEnumPatchesW'],
  [
    Fiddle::TYPE_VOIDP,  # szProduct : LPCWSTR
    -Fiddle::TYPE_INT,  # iPatchIndex : DWORD
    Fiddle::TYPE_VOIDP,  # lpPatchBuf : LPWSTR out
    Fiddle::TYPE_VOIDP,  # lpTransformsBuf : LPWSTR out
    Fiddle::TYPE_VOIDP,  # pcchTransformsBuf : DWORD* in/out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiEnumPatchesW(
        szProduct: *const u16,  // LPCWSTR
        iPatchIndex: u32,  // DWORD
        lpPatchBuf: *mut u16,  // LPWSTR out
        lpTransformsBuf: *mut u16,  // LPWSTR out
        pcchTransformsBuf: *mut u32  // DWORD* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiEnumPatchesW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, uint iPatchIndex, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPatchBuf, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpTransformsBuf, ref uint pcchTransformsBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiEnumPatchesW' -Namespace Win32 -PassThru
# $api::MsiEnumPatchesW(szProduct, iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf)
#uselib "msi.dll"
#func global MsiEnumPatchesW "MsiEnumPatchesW" wptr, wptr, wptr, wptr, wptr
; MsiEnumPatchesW szProduct, iPatchIndex, varptr(lpPatchBuf), varptr(lpTransformsBuf), varptr(pcchTransformsBuf)   ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; iPatchIndex : DWORD -> "wptr"
; lpPatchBuf : LPWSTR out -> "wptr"
; lpTransformsBuf : LPWSTR out -> "wptr"
; pcchTransformsBuf : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiEnumPatchesW "MsiEnumPatchesW" wstr, int, var, var, var
; res = MsiEnumPatchesW(szProduct, iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf)
; szProduct : LPCWSTR -> "wstr"
; iPatchIndex : DWORD -> "int"
; lpPatchBuf : LPWSTR out -> "var"
; lpTransformsBuf : LPWSTR out -> "var"
; pcchTransformsBuf : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiEnumPatchesW(LPCWSTR szProduct, DWORD iPatchIndex, LPWSTR lpPatchBuf, LPWSTR lpTransformsBuf, DWORD* pcchTransformsBuf)
#uselib "msi.dll"
#cfunc global MsiEnumPatchesW "MsiEnumPatchesW" wstr, int, var, var, var
; res = MsiEnumPatchesW(szProduct, iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf)
; szProduct : LPCWSTR -> "wstr"
; iPatchIndex : DWORD -> "int"
; lpPatchBuf : LPWSTR out -> "var"
; lpTransformsBuf : LPWSTR out -> "var"
; pcchTransformsBuf : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiEnumPatchesW = msi.NewProc("MsiEnumPatchesW")
)

// szProduct (LPCWSTR), iPatchIndex (DWORD), lpPatchBuf (LPWSTR out), lpTransformsBuf (LPWSTR out), pcchTransformsBuf (DWORD* in/out)
r1, _, err := procMsiEnumPatchesW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
	uintptr(iPatchIndex),
	uintptr(lpPatchBuf),
	uintptr(lpTransformsBuf),
	uintptr(pcchTransformsBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiEnumPatchesW(
  szProduct: PWideChar;   // LPCWSTR
  iPatchIndex: DWORD;   // DWORD
  lpPatchBuf: PWideChar;   // LPWSTR out
  lpTransformsBuf: PWideChar;   // LPWSTR out
  pcchTransformsBuf: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiEnumPatchesW';
result := DllCall("msi\MsiEnumPatchesW"
    , "WStr", szProduct   ; LPCWSTR
    , "UInt", iPatchIndex   ; DWORD
    , "Ptr", lpPatchBuf   ; LPWSTR out
    , "Ptr", lpTransformsBuf   ; LPWSTR out
    , "Ptr", pcchTransformsBuf   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●MsiEnumPatchesW(szProduct, iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf) = DLL("msi.dll", "dword MsiEnumPatchesW(char*, dword, char*, char*, void*)")
# 呼び出し: MsiEnumPatchesW(szProduct, iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf)
# szProduct : LPCWSTR -> "char*"
# iPatchIndex : DWORD -> "dword"
# lpPatchBuf : LPWSTR out -> "char*"
# lpTransformsBuf : LPWSTR out -> "char*"
# pcchTransformsBuf : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。