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