【www.gdgbn.com--php安装】

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,

本文来源:http://www.gdgbn.com/jiaocheng/12992/