Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › MsiGetProductInfoExW

MsiGetProductInfoExW

関数
インストールコンテキストを指定して製品情報を取得する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiGetProductInfoExW(
    LPCWSTR szProductCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    LPCWSTR szProperty,
    LPWSTR szValue,   // optional
    DWORD* pcchValue   // optional
);

パラメーター

名前方向
szProductCodeLPCWSTRin
szUserSidLPCWSTRinoptional
dwContextMSIINSTALLCONTEXTin
szPropertyLPCWSTRin
szValueLPWSTRoutoptional
pcchValueDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiGetProductInfoExW(
    LPCWSTR szProductCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    LPCWSTR szProperty,
    LPWSTR szValue,   // optional
    DWORD* pcchValue   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiGetProductInfoExW(
    [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 szValue,   // LPWSTR optional, out
    IntPtr pcchValue   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiGetProductInfoExW(
    <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)> szValue As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcchValue As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' szProductCode : LPCWSTR
' szUserSid : LPCWSTR optional
' dwContext : MSIINSTALLCONTEXT
' szProperty : LPCWSTR
' szValue : LPWSTR optional, out
' pcchValue : DWORD* optional, in/out
Declare PtrSafe Function MsiGetProductInfoExW Lib "msi" ( _
    ByVal szProductCode As LongPtr, _
    ByVal szUserSid As LongPtr, _
    ByVal dwContext As Long, _
    ByVal szProperty As LongPtr, _
    ByVal szValue 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

MsiGetProductInfoExW = ctypes.windll.msi.MsiGetProductInfoExW
MsiGetProductInfoExW.restype = wintypes.DWORD
MsiGetProductInfoExW.argtypes = [
    wintypes.LPCWSTR,  # szProductCode : LPCWSTR
    wintypes.LPCWSTR,  # szUserSid : LPCWSTR optional
    ctypes.c_int,  # dwContext : MSIINSTALLCONTEXT
    wintypes.LPCWSTR,  # szProperty : LPCWSTR
    wintypes.LPWSTR,  # szValue : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchValue : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiGetProductInfoExW = Fiddle::Function.new(
  lib['MsiGetProductInfoExW'],
  [
    Fiddle::TYPE_VOIDP,  # szProductCode : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szUserSid : LPCWSTR optional
    Fiddle::TYPE_INT,  # dwContext : MSIINSTALLCONTEXT
    Fiddle::TYPE_VOIDP,  # szProperty : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szValue : 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 MsiGetProductInfoExW(
        szProductCode: *const u16,  // LPCWSTR
        szUserSid: *const u16,  // LPCWSTR optional
        dwContext: i32,  // MSIINSTALLCONTEXT
        szProperty: *const u16,  // LPCWSTR
        szValue: *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 MsiGetProductInfoExW([MarshalAs(UnmanagedType.LPWStr)] string szProductCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, int dwContext, [MarshalAs(UnmanagedType.LPWStr)] string szProperty, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szValue, IntPtr pcchValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetProductInfoExW' -Namespace Win32 -PassThru
# $api::MsiGetProductInfoExW(szProductCode, szUserSid, dwContext, szProperty, szValue, pcchValue)
#uselib "msi.dll"
#func global MsiGetProductInfoExW "MsiGetProductInfoExW" wptr, wptr, wptr, wptr, wptr, wptr
; MsiGetProductInfoExW szProductCode, szUserSid, dwContext, szProperty, varptr(szValue), varptr(pcchValue)   ; 戻り値は stat
; szProductCode : LPCWSTR -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : MSIINSTALLCONTEXT -> "wptr"
; szProperty : LPCWSTR -> "wptr"
; szValue : LPWSTR optional, out -> "wptr"
; pcchValue : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiGetProductInfoExW "MsiGetProductInfoExW" wstr, wstr, int, wstr, var, var
; res = MsiGetProductInfoExW(szProductCode, szUserSid, dwContext, szProperty, szValue, pcchValue)
; szProductCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; szProperty : LPCWSTR -> "wstr"
; szValue : LPWSTR optional, out -> "var"
; pcchValue : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty, LPWSTR szValue, DWORD* pcchValue)
#uselib "msi.dll"
#cfunc global MsiGetProductInfoExW "MsiGetProductInfoExW" wstr, wstr, int, wstr, var, var
; res = MsiGetProductInfoExW(szProductCode, szUserSid, dwContext, szProperty, szValue, pcchValue)
; szProductCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; szProperty : LPCWSTR -> "wstr"
; szValue : LPWSTR optional, out -> "var"
; pcchValue : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetProductInfoExW = msi.NewProc("MsiGetProductInfoExW")
)

// szProductCode (LPCWSTR), szUserSid (LPCWSTR optional), dwContext (MSIINSTALLCONTEXT), szProperty (LPCWSTR), szValue (LPWSTR optional, out), pcchValue (DWORD* optional, in/out)
r1, _, err := procMsiGetProductInfoExW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCode))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szUserSid))),
	uintptr(dwContext),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProperty))),
	uintptr(szValue),
	uintptr(pcchValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiGetProductInfoExW(
  szProductCode: PWideChar;   // LPCWSTR
  szUserSid: PWideChar;   // LPCWSTR optional
  dwContext: Integer;   // MSIINSTALLCONTEXT
  szProperty: PWideChar;   // LPCWSTR
  szValue: PWideChar;   // LPWSTR optional, out
  pcchValue: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiGetProductInfoExW';
result := DllCall("msi\MsiGetProductInfoExW"
    , "WStr", szProductCode   ; LPCWSTR
    , "WStr", szUserSid   ; LPCWSTR optional
    , "Int", dwContext   ; MSIINSTALLCONTEXT
    , "WStr", szProperty   ; LPCWSTR
    , "Ptr", szValue   ; LPWSTR optional, out
    , "Ptr", pcchValue   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiGetProductInfoExW(szProductCode, szUserSid, dwContext, szProperty, szValue, pcchValue) = DLL("msi.dll", "dword MsiGetProductInfoExW(char*, char*, int, char*, char*, void*)")
# 呼び出し: MsiGetProductInfoExW(szProductCode, szUserSid, dwContext, szProperty, szValue, pcchValue)
# szProductCode : LPCWSTR -> "char*"
# szUserSid : LPCWSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# szProperty : LPCWSTR -> "char*"
# szValue : LPWSTR optional, out -> "char*"
# pcchValue : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。