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