Hi,
dann sollte man vielleicht das ganze Objekt-Gedöns weglassen
und mit der DLL arbeiten.
Ich habe mich mal dran versucht und die Objekteigenschaft ProductsEx in den Dll-Funktionsaufruf MsiEnumProductsExW umgesetzt. Sollte (wenn es denn klappt) auch deutlich schneller sein.
Kleiner Aufruf an progandy: Schau bitte mal drüber, ob das OK ist.
Habs noch nicht getestet. Und bin im Moment auch zu müde. ![]()
Ich hänge mal die OriginalInfo zu dieser Funktion mit an.
Es werden noch die Werte für einige Konstanten benötigt, aber da kannst du ja selber mal schauen. Nimm es als Arbeitsansatz. ![]()
Func MsiEnumProductsEx
Func MsiEnumProductsEx($strProductCode, $strUserSid, $dwContext, $dwIndex)
Local $szProductCode = DllStructCreate('wchar[' & StringLen($strProductCode)+1 & ']')
Local $szUserSid = DllStructCreate('wchar[' & StringLen($strUserSid)+1 & ']')
Local $pdwInstalledContext = DllStructCreate('int')
Local $szSid = DllStructCreate('wchar[128]')
Local $pcchSid = DllStructCreate('int')
DllStructSetData($szProductCode, 1, $strProductCode)
DllStructSetData($szUserSid, 1, $strUserSid)
DllStructSetData($pdwInstalledContext, 1, $dwContext)
Local $ret = DllCall('Msi.dll', 'uint', 'MsiEnumProductsExW', _
'ptr', DllStructGetPtr($szProductCode), _
'ptr', DllStructGetPtr($szUserSid), _
'dword', $dwContext, _
'dword', $dwIndex, _
'wchar', 'szInstalledProductCode[40]', _
'ptr', DllStructGetPtr($pdwInstalledContext), _
'ptr', DllStructGetPtr($szSid), _
'ptr', DllStructGetPtr($pcchSid))
Local $aOut[4]
$aOut[0] = $ret[5] ; ProductCode GUID
$aOut[1] = DllStructGetData($pdwInstalledContext, 1); can be MSIINSTALLCONTEXT_USERMANAGED, MSIINSTALLCONTEXT_USERUNMANAGED, MSIINSTALLCONTEXT_MACHINE
$aOut[2] = DllStructGetData($szSid, 1) ; string SID of the account under which this product instance exists
$aOut[3] = DllStructGetData($pcchSid, 1) ; number of TCHAR in the szSid buffer
Return $aOut
EndFunc
Und hier die Infos aus der Beschreibung zur Dll:
Spoiler anzeigen
#cs
[/autoit] [autoit][/autoit] [autoit]UINT MsiEnumProductsEx(
__in_opt LPCTSTR szProductCode,
__in LPCTSTR szUserSid,
__in DWORD dwContext,
__in DWORD dwIndex,
__out_opt TCHAR szInstalledProductCode[39],
__out_opt MSIINSTALLCONTEXT *pdwInstalledContext,
__out_opt LPTSTR szSid,
__inout_opt LPDWORD pcchSid
szProductCode [in, optional]
ProductCode GUID of the product to be enumerated. Only instances of products within the scope of the context specified by the
szUserSid and dwContext parameters are enumerated. This parameter can be set to NULL to enumerate all products in the
specified context.
szUserSid [in]
Null-terminated string that specifies a security identifier (SID) that restricts the context of enumeration.
The special SID string s-1-1-0 (Everyone) specifies enumeration across all users in the system.
A SID value other than s-1-1-0 is considered a user-SID and restricts enumeration to the current user or any user in the system.
This parameter can be set to null to restrict the enumeration scope to the current user.
SID Meaning
type
NULL Specifies the currently logged-on user.
[/autoit] [autoit][/autoit] [autoit]User SID Specifies enumeration for a particular user in the system. An example of user SID is
"S-1-3-64-2415071341-1358098788-3127455600-2561".
s-1-1-0 Specifies enumeration across all users in the system.
[/autoit] [autoit][/autoit] [autoit]Note:
The special SID string s-1-5-18 (System) cannot be used to enumerate products or patches installed as per-machine.
When dwContext is set to MSIINSTALLCONTEXT_MACHINE only, szUserSid must be null.
dwContext [in]
Restricts the enumeration to a context. This parameter can be any one or a combination of the values shown in the following table.
Context Meaning
MSIINSTALLCONTEXT_USERMANAGED Enumeration extended to all per–user–managed installations for the users specified by szUserSid.
An invalid SID returns no items.
MSIINSTALLCONTEXT_USERUNMANAGED Enumeration extended to all per–user–unmanaged installations for the users specified by szUserSid.
An invalid SID returns no items.
MSIINSTALLCONTEXT_MACHINE Enumeration extended to all per-machine installations. When dwInstallContext is set
to MSIINSTALLCONTEXT_MACHINE only, the szUserSID parameter must be null.
dwIndex [in]
Specifies the index of the product to retrieve. This parameter must be zero for the first call to the MsiEnumProductsEx function
and then incremented for subsequent calls. The index should be incremented, only if the previous call has returned ERROR_SUCCESS.
Because products are not ordered, any new product has an arbitrary index. This means that the function can return products in any
order.
szInstalledProductCode [out, optional]
Null-terminated string of TCHAR that gives the ProductCode GUID of the product instance being enumerated. This parameter can be
null.
pdwInstalledContext [out, optional]
Returns the context of the product instance being enumerated. The output value can be MSIINSTALLCONTEXT_USERMANAGED,
MSIINSTALLCONTEXT_USERUNMANAGED, or MSIINSTALLCONTEXT_MACHINE. This parameter can be null.
szSid [out, optional]
An output buffer that receives the string SID of the account under which this product instance exists. This buffer returns an
empty string for an instance installed in a per-machine context.
This buffer should be large enough to contain the SID. If the buffer is too small, the function returns ERROR_MORE_DATA (0x000000EA)
and sets *pcchSid to the number of TCHAR in the SID, not including the terminating NULL character.
If szSid is set to NULL and pcchSid is set to a valid pointer, the function returns ERROR_SUCCESS (0x00000000) and sets
*pcchSid to the number of TCHAR in the value, not including the terminating NULL. The function can then be called again to
retrieve the value, with the szSid buffer large enough to contain *pcchSid + 1 characters.
If szSid and pcchSid are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without retrieving the value.
pcchSid [in, out, optional]
When calling the function, this parameter should be a pointer to a variable that specifies the number of TCHAR in the
szSid buffer. When the function returns, this parameter is set to the size of the requested value whether or not the function
copies the value into the specified buffer. The size is returned as the number of TCHAR in the requested value, not including
the terminating null character.
This parameter can be set to NULL only if szSid is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER (0x00000057).
#ce