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

MsiGetPatchInfoW

関数
適用済みパッチの情報を取得する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiGetPatchInfoW(
    LPCWSTR szPatch,
    LPCWSTR szAttribute,
    LPWSTR lpValueBuf,   // optional
    DWORD* pcchValueBuf   // optional
);

パラメーター

名前方向
szPatchLPCWSTRin
szAttributeLPCWSTRin
lpValueBufLPWSTRoutoptional
pcchValueBufDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiGetPatchInfoW(
    LPCWSTR szPatch,
    LPCWSTR szAttribute,
    LPWSTR lpValueBuf,   // optional
    DWORD* pcchValueBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiGetPatchInfoW(
    [MarshalAs(UnmanagedType.LPWStr)] string szPatch,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szAttribute,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpValueBuf,   // LPWSTR optional, out
    IntPtr pcchValueBuf   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiGetPatchInfoW(
    <MarshalAs(UnmanagedType.LPWStr)> szPatch As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szAttribute As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpValueBuf As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcchValueBuf As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' szPatch : LPCWSTR
' szAttribute : LPCWSTR
' lpValueBuf : LPWSTR optional, out
' pcchValueBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiGetPatchInfoW Lib "msi" ( _
    ByVal szPatch As LongPtr, _
    ByVal szAttribute As LongPtr, _
    ByVal lpValueBuf As LongPtr, _
    ByVal pcchValueBuf 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

MsiGetPatchInfoW = ctypes.windll.msi.MsiGetPatchInfoW
MsiGetPatchInfoW.restype = wintypes.DWORD
MsiGetPatchInfoW.argtypes = [
    wintypes.LPCWSTR,  # szPatch : LPCWSTR
    wintypes.LPCWSTR,  # szAttribute : LPCWSTR
    wintypes.LPWSTR,  # lpValueBuf : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchValueBuf : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetPatchInfoW = msi.NewProc("MsiGetPatchInfoW")
)

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