Type
PsoftItem = ^ TSoftItem;
TSoftItem = packed record
SoftName: string;
SoftVer: string;
Path: string;
End;
Procedure ReadLocalSoftByMSI (aList: TList );
Var
Index: Integer;
Buf: array [0 .. 38] of char;
PropBuf: PChar;
Hr: UINT;
Len: DWORD;
P: PSoftItem;
Begin
If not Assigned (aList) then exit;
For Index: = aList. Count-1 downto 0 do
Begin
P: = aList. Items [Index];
If Assigned (P) then DisPose (P );
End;
AList. Clear;
Index: = 0;
Hr: = MsiEnumProducts (Index, Buf );
While hr = ERROR_SUCCESS do
Begin
New (P );
Len: = 0;
MsiGetProductInfo (Buf, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, nil, @ len );
Inc (Len );
PropBuf: = AllocMem (len );
Try
MsiGetProductInfo (Buf, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, PropBuf, @ len );
P ^. SoftName: = PropBuf;
Finally
FreeMem (PropBuf );
End;
Len: = 0;
MsiGetProductInfo (Buf, INSTALLPROPERTY_INSTALLLOCATION, nil, @ len );
Inc (Len );
PropBuf: = AllocMem (len );
Try
MsiGetProductInfo (Buf, INSTALLPROPERTY_INSTALLLOCATION, PropBuf, @ len );
P ^. Path: = PropBuf;
Finally
FreeMem (PropBuf );
End;
Len: = 0;
MsiGetProductInfo (Buf, INSTALLPROPERTY_VERSIONSTRING, nil, @ len );
Inc (Len );
PropBuf: = AllocMem (len );
Try
MsiGetProductInfo (Buf, INSTALLPROPERTY_VERSIONSTRING, PropBuf,