ホーム › System.ApplicationInstallationAndServicing › MsiGetPatchInfoExA
MsiGetPatchInfoExA
関数コンテキスト指定でパッチの詳細情報を取得する(ANSI版)。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiGetPatchInfoExA(
LPCSTR szPatchCode,
LPCSTR szProductCode,
LPCSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
LPCSTR szProperty,
LPSTR lpValue, // optional
DWORD* pcchValue // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| szPatchCode | LPCSTR | in | 情報を取得するパッチのパッチコード(GUID)文字列。ANSI。 |
| szProductCode | LPCSTR | in | パッチが適用された対象製品の製品コード(GUID)文字列。 |
| szUserSid | LPCSTR | inoptional | ユーザーごとのインストールコンテキストを示すSID文字列。NULL可で現ユーザー。 |
| dwContext | MSIINSTALLCONTEXT | in | インストールコンテキストを示すMSIINSTALLCONTEXT列挙値。 |
| szProperty | LPCSTR | in | 取得するパッチプロパティ名(INSTALLPROPERTY_*)。 |
| lpValue | LPSTR | outoptional | プロパティ値を受け取るバッファー。NULL可でサイズ取得のみ。 |
| pcchValue | DWORD* | inoutoptional | lpValueのサイズ(文字数)を渡し、必要長を受け取るポインター。 |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiGetPatchInfoExA(
LPCSTR szPatchCode,
LPCSTR szProductCode,
LPCSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
LPCSTR szProperty,
LPSTR lpValue, // optional
DWORD* pcchValue // optional
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetPatchInfoExA(
[MarshalAs(UnmanagedType.LPStr)] string szPatchCode, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szProductCode, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szUserSid, // LPCSTR optional
int dwContext, // MSIINSTALLCONTEXT
[MarshalAs(UnmanagedType.LPStr)] string szProperty, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpValue, // LPSTR optional, out
IntPtr pcchValue // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetPatchInfoExA(
<MarshalAs(UnmanagedType.LPStr)> szPatchCode As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szProductCode As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szUserSid As String, ' LPCSTR optional
dwContext As Integer, ' MSIINSTALLCONTEXT
<MarshalAs(UnmanagedType.LPStr)> szProperty As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> lpValue As System.Text.StringBuilder, ' LPSTR optional, out
pcchValue As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' szPatchCode : LPCSTR
' szProductCode : LPCSTR
' szUserSid : LPCSTR optional
' dwContext : MSIINSTALLCONTEXT
' szProperty : LPCSTR
' lpValue : LPSTR optional, out
' pcchValue : DWORD* optional, in/out
Declare PtrSafe Function MsiGetPatchInfoExA Lib "msi" ( _
ByVal szPatchCode As String, _
ByVal szProductCode As String, _
ByVal szUserSid As String, _
ByVal dwContext As Long, _
ByVal szProperty As String, _
ByVal lpValue As String, _
ByVal pcchValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiGetPatchInfoExA = ctypes.windll.msi.MsiGetPatchInfoExA
MsiGetPatchInfoExA.restype = wintypes.DWORD
MsiGetPatchInfoExA.argtypes = [
wintypes.LPCSTR, # szPatchCode : LPCSTR
wintypes.LPCSTR, # szProductCode : LPCSTR
wintypes.LPCSTR, # szUserSid : LPCSTR optional
ctypes.c_int, # dwContext : MSIINSTALLCONTEXT
wintypes.LPCSTR, # szProperty : LPCSTR
wintypes.LPSTR, # lpValue : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchValue : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetPatchInfoExA = Fiddle::Function.new(
lib['MsiGetPatchInfoExA'],
[
Fiddle::TYPE_VOIDP, # szPatchCode : LPCSTR
Fiddle::TYPE_VOIDP, # szProductCode : LPCSTR
Fiddle::TYPE_VOIDP, # szUserSid : LPCSTR optional
Fiddle::TYPE_INT, # dwContext : MSIINSTALLCONTEXT
Fiddle::TYPE_VOIDP, # szProperty : LPCSTR
Fiddle::TYPE_VOIDP, # lpValue : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchValue : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiGetPatchInfoExA(
szPatchCode: *const u8, // LPCSTR
szProductCode: *const u8, // LPCSTR
szUserSid: *const u8, // LPCSTR optional
dwContext: i32, // MSIINSTALLCONTEXT
szProperty: *const u8, // LPCSTR
lpValue: *mut u8, // LPSTR optional, out
pcchValue: *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 MsiGetPatchInfoExA([MarshalAs(UnmanagedType.LPStr)] string szPatchCode, [MarshalAs(UnmanagedType.LPStr)] string szProductCode, [MarshalAs(UnmanagedType.LPStr)] string szUserSid, int dwContext, [MarshalAs(UnmanagedType.LPStr)] string szProperty, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpValue, IntPtr pcchValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetPatchInfoExA' -Namespace Win32 -PassThru
# $api::MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue)#uselib "msi.dll"
#func global MsiGetPatchInfoExA "MsiGetPatchInfoExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MsiGetPatchInfoExA szPatchCode, szProductCode, szUserSid, dwContext, szProperty, varptr(lpValue), varptr(pcchValue) ; 戻り値は stat
; szPatchCode : LPCSTR -> "sptr"
; szProductCode : LPCSTR -> "sptr"
; szUserSid : LPCSTR optional -> "sptr"
; dwContext : MSIINSTALLCONTEXT -> "sptr"
; szProperty : LPCSTR -> "sptr"
; lpValue : LPSTR optional, out -> "sptr"
; pcchValue : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiGetPatchInfoExA "MsiGetPatchInfoExA" str, str, str, int, str, var, var ; res = MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue) ; szPatchCode : LPCSTR -> "str" ; szProductCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCSTR -> "str" ; lpValue : LPSTR optional, out -> "var" ; pcchValue : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiGetPatchInfoExA "MsiGetPatchInfoExA" str, str, str, int, str, sptr, sptr ; res = MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, varptr(lpValue), varptr(pcchValue)) ; szPatchCode : LPCSTR -> "str" ; szProductCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCSTR -> "str" ; lpValue : LPSTR optional, out -> "sptr" ; pcchValue : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MsiGetPatchInfoExA(LPCSTR szPatchCode, LPCSTR szProductCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCSTR szProperty, LPSTR lpValue, DWORD* pcchValue) #uselib "msi.dll" #cfunc global MsiGetPatchInfoExA "MsiGetPatchInfoExA" str, str, str, int, str, var, var ; res = MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue) ; szPatchCode : LPCSTR -> "str" ; szProductCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCSTR -> "str" ; lpValue : LPSTR optional, out -> "var" ; pcchValue : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiGetPatchInfoExA(LPCSTR szPatchCode, LPCSTR szProductCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCSTR szProperty, LPSTR lpValue, DWORD* pcchValue) #uselib "msi.dll" #cfunc global MsiGetPatchInfoExA "MsiGetPatchInfoExA" str, str, str, int, str, intptr, intptr ; res = MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, varptr(lpValue), varptr(pcchValue)) ; szPatchCode : LPCSTR -> "str" ; szProductCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCSTR -> "str" ; lpValue : LPSTR optional, out -> "intptr" ; pcchValue : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiGetPatchInfoExA = msi.NewProc("MsiGetPatchInfoExA")
)
// szPatchCode (LPCSTR), szProductCode (LPCSTR), szUserSid (LPCSTR optional), dwContext (MSIINSTALLCONTEXT), szProperty (LPCSTR), lpValue (LPSTR optional, out), pcchValue (DWORD* optional, in/out)
r1, _, err := procMsiGetPatchInfoExA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szPatchCode))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProductCode))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szUserSid))),
uintptr(dwContext),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProperty))),
uintptr(lpValue),
uintptr(pcchValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiGetPatchInfoExA(
szPatchCode: PAnsiChar; // LPCSTR
szProductCode: PAnsiChar; // LPCSTR
szUserSid: PAnsiChar; // LPCSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT
szProperty: PAnsiChar; // LPCSTR
lpValue: PAnsiChar; // LPSTR optional, out
pcchValue: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiGetPatchInfoExA';result := DllCall("msi\MsiGetPatchInfoExA"
, "AStr", szPatchCode ; LPCSTR
, "AStr", szProductCode ; LPCSTR
, "AStr", szUserSid ; LPCSTR optional
, "Int", dwContext ; MSIINSTALLCONTEXT
, "AStr", szProperty ; LPCSTR
, "Ptr", lpValue ; LPSTR optional, out
, "Ptr", pcchValue ; DWORD* optional, in/out
, "UInt") ; return: DWORD●MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue) = DLL("msi.dll", "dword MsiGetPatchInfoExA(char*, char*, char*, int, char*, char*, void*)")
# 呼び出し: MsiGetPatchInfoExA(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue)
# szPatchCode : LPCSTR -> "char*"
# szProductCode : LPCSTR -> "char*"
# szUserSid : LPCSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# szProperty : LPCSTR -> "char*"
# lpValue : LPSTR optional, out -> "char*"
# pcchValue : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。