ホーム › System.ApplicationInstallationAndServicing › MsiGetPatchInfoExW
MsiGetPatchInfoExW
関数コンテキスト指定でパッチの詳細情報を取得する(Unicode版)。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiGetPatchInfoExW(
LPCWSTR szPatchCode,
LPCWSTR szProductCode,
LPCWSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
LPCWSTR szProperty,
LPWSTR lpValue, // optional
DWORD* pcchValue // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szPatchCode | LPCWSTR | in |
| szProductCode | LPCWSTR | in |
| szUserSid | LPCWSTR | inoptional |
| dwContext | MSIINSTALLCONTEXT | in |
| szProperty | LPCWSTR | in |
| lpValue | LPWSTR | outoptional |
| pcchValue | DWORD* | inoutoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiGetPatchInfoExW(
LPCWSTR szPatchCode,
LPCWSTR szProductCode,
LPCWSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
LPCWSTR szProperty,
LPWSTR lpValue, // optional
DWORD* pcchValue // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiGetPatchInfoExW(
[MarshalAs(UnmanagedType.LPWStr)] string szPatchCode, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szProductCode, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szUserSid, // LPCWSTR optional
int dwContext, // MSIINSTALLCONTEXT
[MarshalAs(UnmanagedType.LPWStr)] string szProperty, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpValue, // LPWSTR optional, out
IntPtr pcchValue // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiGetPatchInfoExW(
<MarshalAs(UnmanagedType.LPWStr)> szPatchCode As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szProductCode As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szUserSid As String, ' LPCWSTR optional
dwContext As Integer, ' MSIINSTALLCONTEXT
<MarshalAs(UnmanagedType.LPWStr)> szProperty As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpValue As System.Text.StringBuilder, ' LPWSTR optional, out
pcchValue As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' szPatchCode : LPCWSTR
' szProductCode : LPCWSTR
' szUserSid : LPCWSTR optional
' dwContext : MSIINSTALLCONTEXT
' szProperty : LPCWSTR
' lpValue : LPWSTR optional, out
' pcchValue : DWORD* optional, in/out
Declare PtrSafe Function MsiGetPatchInfoExW Lib "msi" ( _
ByVal szPatchCode As LongPtr, _
ByVal szProductCode As LongPtr, _
ByVal szUserSid As LongPtr, _
ByVal dwContext As Long, _
ByVal szProperty As LongPtr, _
ByVal lpValue As LongPtr, _
ByVal pcchValue 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
MsiGetPatchInfoExW = ctypes.windll.msi.MsiGetPatchInfoExW
MsiGetPatchInfoExW.restype = wintypes.DWORD
MsiGetPatchInfoExW.argtypes = [
wintypes.LPCWSTR, # szPatchCode : LPCWSTR
wintypes.LPCWSTR, # szProductCode : LPCWSTR
wintypes.LPCWSTR, # szUserSid : LPCWSTR optional
ctypes.c_int, # dwContext : MSIINSTALLCONTEXT
wintypes.LPCWSTR, # szProperty : LPCWSTR
wintypes.LPWSTR, # lpValue : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchValue : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetPatchInfoExW = Fiddle::Function.new(
lib['MsiGetPatchInfoExW'],
[
Fiddle::TYPE_VOIDP, # szPatchCode : LPCWSTR
Fiddle::TYPE_VOIDP, # szProductCode : LPCWSTR
Fiddle::TYPE_VOIDP, # szUserSid : LPCWSTR optional
Fiddle::TYPE_INT, # dwContext : MSIINSTALLCONTEXT
Fiddle::TYPE_VOIDP, # szProperty : LPCWSTR
Fiddle::TYPE_VOIDP, # lpValue : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # pcchValue : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiGetPatchInfoExW(
szPatchCode: *const u16, // LPCWSTR
szProductCode: *const u16, // LPCWSTR
szUserSid: *const u16, // LPCWSTR optional
dwContext: i32, // MSIINSTALLCONTEXT
szProperty: *const u16, // LPCWSTR
lpValue: *mut u16, // LPWSTR 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.Unicode)]
public static extern uint MsiGetPatchInfoExW([MarshalAs(UnmanagedType.LPWStr)] string szPatchCode, [MarshalAs(UnmanagedType.LPWStr)] string szProductCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, int dwContext, [MarshalAs(UnmanagedType.LPWStr)] string szProperty, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpValue, IntPtr pcchValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetPatchInfoExW' -Namespace Win32 -PassThru
# $api::MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue)#uselib "msi.dll"
#func global MsiGetPatchInfoExW "MsiGetPatchInfoExW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; MsiGetPatchInfoExW szPatchCode, szProductCode, szUserSid, dwContext, szProperty, varptr(lpValue), varptr(pcchValue) ; 戻り値は stat
; szPatchCode : LPCWSTR -> "wptr"
; szProductCode : LPCWSTR -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : MSIINSTALLCONTEXT -> "wptr"
; szProperty : LPCWSTR -> "wptr"
; lpValue : LPWSTR optional, out -> "wptr"
; pcchValue : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiGetPatchInfoExW "MsiGetPatchInfoExW" wstr, wstr, wstr, int, wstr, var, var ; res = MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue) ; szPatchCode : LPCWSTR -> "wstr" ; szProductCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCWSTR -> "wstr" ; lpValue : LPWSTR optional, out -> "var" ; pcchValue : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiGetPatchInfoExW "MsiGetPatchInfoExW" wstr, wstr, wstr, int, wstr, sptr, sptr ; res = MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, varptr(lpValue), varptr(pcchValue)) ; szPatchCode : LPCWSTR -> "wstr" ; szProductCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCWSTR -> "wstr" ; lpValue : LPWSTR optional, out -> "sptr" ; pcchValue : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MsiGetPatchInfoExW(LPCWSTR szPatchCode, LPCWSTR szProductCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty, LPWSTR lpValue, DWORD* pcchValue) #uselib "msi.dll" #cfunc global MsiGetPatchInfoExW "MsiGetPatchInfoExW" wstr, wstr, wstr, int, wstr, var, var ; res = MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue) ; szPatchCode : LPCWSTR -> "wstr" ; szProductCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCWSTR -> "wstr" ; lpValue : LPWSTR optional, out -> "var" ; pcchValue : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiGetPatchInfoExW(LPCWSTR szPatchCode, LPCWSTR szProductCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty, LPWSTR lpValue, DWORD* pcchValue) #uselib "msi.dll" #cfunc global MsiGetPatchInfoExW "MsiGetPatchInfoExW" wstr, wstr, wstr, int, wstr, intptr, intptr ; res = MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, varptr(lpValue), varptr(pcchValue)) ; szPatchCode : LPCWSTR -> "wstr" ; szProductCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT -> "int" ; szProperty : LPCWSTR -> "wstr" ; lpValue : LPWSTR 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")
procMsiGetPatchInfoExW = msi.NewProc("MsiGetPatchInfoExW")
)
// szPatchCode (LPCWSTR), szProductCode (LPCWSTR), szUserSid (LPCWSTR optional), dwContext (MSIINSTALLCONTEXT), szProperty (LPCWSTR), lpValue (LPWSTR optional, out), pcchValue (DWORD* optional, in/out)
r1, _, err := procMsiGetPatchInfoExW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szPatchCode))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCode))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szUserSid))),
uintptr(dwContext),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProperty))),
uintptr(lpValue),
uintptr(pcchValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiGetPatchInfoExW(
szPatchCode: PWideChar; // LPCWSTR
szProductCode: PWideChar; // LPCWSTR
szUserSid: PWideChar; // LPCWSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT
szProperty: PWideChar; // LPCWSTR
lpValue: PWideChar; // LPWSTR optional, out
pcchValue: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiGetPatchInfoExW';result := DllCall("msi\MsiGetPatchInfoExW"
, "WStr", szPatchCode ; LPCWSTR
, "WStr", szProductCode ; LPCWSTR
, "WStr", szUserSid ; LPCWSTR optional
, "Int", dwContext ; MSIINSTALLCONTEXT
, "WStr", szProperty ; LPCWSTR
, "Ptr", lpValue ; LPWSTR optional, out
, "Ptr", pcchValue ; DWORD* optional, in/out
, "UInt") ; return: DWORD●MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue) = DLL("msi.dll", "dword MsiGetPatchInfoExW(char*, char*, char*, int, char*, char*, void*)")
# 呼び出し: MsiGetPatchInfoExW(szPatchCode, szProductCode, szUserSid, dwContext, szProperty, lpValue, pcchValue)
# szPatchCode : LPCWSTR -> "char*"
# szProductCode : LPCWSTR -> "char*"
# szUserSid : LPCWSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# szProperty : LPCWSTR -> "char*"
# lpValue : LPWSTR optional, out -> "char*"
# pcchValue : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。