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