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