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

MsiGetPatchInfoA

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

シグネチャ

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiGetPatchInfoA(
    LPCSTR szPatch,
    LPCSTR szAttribute,
    LPSTR lpValueBuf,   // optional
    DWORD* pcchValueBuf   // optional
);

パラメーター

名前方向
szPatchLPCSTRin
szAttributeLPCSTRin
lpValueBufLPSTRoutoptional
pcchValueBufDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiGetPatchInfoA(
    LPCSTR szPatch,
    LPCSTR szAttribute,
    LPSTR lpValueBuf,   // optional
    DWORD* pcchValueBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetPatchInfoA(
    [MarshalAs(UnmanagedType.LPStr)] string szPatch,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szAttribute,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpValueBuf,   // LPSTR optional, out
    IntPtr pcchValueBuf   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetPatchInfoA(
    <MarshalAs(UnmanagedType.LPStr)> szPatch As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szAttribute As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpValueBuf As System.Text.StringBuilder,   ' LPSTR optional, out
    pcchValueBuf As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' szPatch : LPCSTR
' szAttribute : LPCSTR
' lpValueBuf : LPSTR optional, out
' pcchValueBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiGetPatchInfoA Lib "msi" ( _
    ByVal szPatch As String, _
    ByVal szAttribute As String, _
    ByVal lpValueBuf As String, _
    ByVal pcchValueBuf As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetPatchInfoA = msi.NewProc("MsiGetPatchInfoA")
)

// szPatch (LPCSTR), szAttribute (LPCSTR), lpValueBuf (LPSTR optional, out), pcchValueBuf (DWORD* optional, in/out)
r1, _, err := procMsiGetPatchInfoA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szPatch))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szAttribute))),
	uintptr(lpValueBuf),
	uintptr(pcchValueBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiGetPatchInfoA(
  szPatch: PAnsiChar;   // LPCSTR
  szAttribute: PAnsiChar;   // LPCSTR
  lpValueBuf: PAnsiChar;   // LPSTR optional, out
  pcchValueBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiGetPatchInfoA';
result := DllCall("msi\MsiGetPatchInfoA"
    , "AStr", szPatch   ; LPCSTR
    , "AStr", szAttribute   ; LPCSTR
    , "Ptr", lpValueBuf   ; LPSTR optional, out
    , "Ptr", pcchValueBuf   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiGetPatchInfoA(szPatch, szAttribute, lpValueBuf, pcchValueBuf) = DLL("msi.dll", "dword MsiGetPatchInfoA(char*, char*, char*, void*)")
# 呼び出し: MsiGetPatchInfoA(szPatch, szAttribute, lpValueBuf, pcchValueBuf)
# szPatch : LPCSTR -> "char*"
# szAttribute : LPCSTR -> "char*"
# lpValueBuf : LPSTR optional, out -> "char*"
# pcchValueBuf : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。