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