This software and its source code (if available) are licensed under the Apache-2.0 license (unless otherwise specified) which DOES NOT APPLY to any third-party code (such as zlib for example) and borrowed Assembler code (ripped code from other software executable files).
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj, ComCtrls, XPMan;
type
TForm1 = class(TForm)
Button1: TButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
ListView1: TListView;
ListView2: TListView;
ListView3: TListView;
ListView4: TListView;
Label1: TLabel;
Edit1: TEdit;
OpenDialog1: TOpenDialog;
Button2: TButton;
Label2: TLabel;
XPManifest1: TXPManifest;
procedure ListView1Click(Sender: TObject);
procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
procedure ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure UpdateLists(FName: String);
procedure UpdateSummaryInfo(FName: String);
procedure UpdatePropertyList(FName: String);
procedure UpdateFileList(FName: String);
procedure UpdateRegistryList(FName: String);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Const
propList: Array[1..19] Of String = (
{ 1} 'Codepage',
{ 2} 'Title',
{ 3} 'Subject',
{ 4} 'Author',
{ 5} 'Keywords',
{ 6} 'Comments',
{ 7} 'Template',
{ 8} 'LastAuthor',
{ 9} 'Revision',
{10} '',
{11} 'Printed',
{12} 'Created',
{13} 'Saved',
{14} 'Pages',
{15} 'Words',
{16} 'Characters',
{17} '',
{18} 'Application',
{19} 'Security'
);
propListDesc: Array[1..19] Of String = (
{ 1} 'ANSI codepage of text strings in summary information only',
{ 2} 'Package type, e.g. Installation Database',
{ 3} 'Product full name or description',
{ 4} 'Creator, typically vendor name',
{ 5} 'List of keywords for use by file browsers',
{ 6} 'Description of purpose or use of package',
{ 7} 'Target system: Platform(s);Language(s)',
{ 8} 'Used for transforms only: New target: Platform(s);Language(s)',
{ 9} 'Package code GUID, for transforms contains old and new info',
{10} '',
{11} 'Date and time of installation image, same as Created if CD',
{12} 'Date and time of package creation',
{13} 'Date and time of last package modification',
{14} 'Minimum Windows Installer version required: Major * 100 + Minor',
{15} 'Source flags: 1=short names, 2=compressed, 4=network image',
{16} 'Used for transforms only: validation and error flags',
{17} '',
{18} 'Application associated with file, "Windows Installer" For MSI',
{19} '0=Read/write 1=Readonly recommended 2=Readonly enforced'
);
Var SortDirect: ShortInt = 1;
procedure TForm1.Button1Click(Sender: TObject);
begin
If OpenDialog1.Execute Then UpdateLists(OpenDialog1.FileName);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.UpdateLists(FName: String);
Begin
ListView1.Enabled:=True;
ListView2.Enabled:=True;
ListView3.Enabled:=True;
ListView4.Enabled:=True;
ListView1.Clear;
ListView2.Clear;
ListView3.Clear;
ListView4.Clear;
Edit1.Text:=FName;
UpdateSummaryInfo(FName);
UpdatePropertyList(FName);
UpdateFileList(FName);
UpdateRegistryList(FName);
End;
Procedure TForm1.UpdateSummaryInfo(FName: String);
Var installer, suminfo, value, msdb: Variant;
SumInfoCount, iProp: Integer;
Begin
installer := CreateOLEObject('WindowsInstaller.Installer');
msdb := installer.OpenDatabase(FName, 0);
sumInfo := msdb.SummaryInformation;
SumInfoCount := 0;
For iProp := 1 To Length(propList) Do
Begin
If propList[iProp]<>'' Then
Begin
value := sumInfo.Property[iProp];
ListView1.Items.Add.Caption:=propList[iProp];
ListView1.Items[SumInfoCount].SubItems.Add(value);
SumInfoCount := SumInfoCount + 1;
End;
End;
If SumInfoCount < 1 Then
Begin
ListView1.Items.Add.Caption:='None Found';
ListView1.Enabled:=False;
End;
installer := '';
sumInfo := '';
End;
Procedure TForm1.UpdatePropertyList(FName: String);
Var MSIobj, MSIdb, MSIView, MSIrecords: Variant;
PropCount: Integer;
Name, Value: String;
begin
MSIobj := CreateOLEObject('WindowsInstaller.Installer');
MSIdb := MSIobj.OpenDatabase(FName, 0);
MSIView := MSIdb.OpenView('SELECT Property,Value FROM Property');
MSIView.Execute;
PropCount:=0;
MSIrecords := MSIView.Fetch;
While IDispatch(MSIrecords)<>Nil Do
Begin
Name:=MSIrecords.StringData[1];
If Pos('|', Name)<>0 Then
Name := Copy(Name, Pos('|', Name) + 1, Length(Name));
Value := MSIrecords.StringData[2];
If Name <> '' Then
Begin
ListView2.Items.Add.Caption:=Name;
ListView2.Items[PropCount].SubItems.Add(Value);
PropCount := PropCount + 1;
End;
Try
MSIrecords := MSIView.Fetch;
Except
End;
End;
If PropCount < 1 Then
Begin
ListView2.Items.Add.Caption:='None Found';
ListView2.Enabled:=False;
End;
end;
Procedure TForm1.UpdateFileList(FName: String);
Var MSIobj, MSIdb, MSIView, MSIrecords: Variant;
PropCount: Integer;
Name, Version, Size: String;
begin
MSIobj := CreateOLEObject('WindowsInstaller.Installer');
MSIdb := MSIobj.OpenDatabase(FName, 0);
MSIView := MSIdb.OpenView('SELECT File.FileName,File.Version,File.FileSize FROM File');
MSIView.Execute;
PropCount:=0;
MSIrecords := MSIView.Fetch;
While IDispatch(MSIrecords)<>Nil Do
Begin
Name:=MSIrecords.StringData[1];
If Pos('|', Name)<>0 Then
Name := Copy(Name, Pos('|', Name) + 1, Length(Name));
Version := MSIrecords.StringData[2];
Size := MSIrecords.StringData[3];
If Name <> '' Then
Begin
ListView3.Items.Add.Caption:=Name;
ListView3.Items[PropCount].SubItems.Add(Version);
ListView3.Items[PropCount].SubItems.Add(Size);
PropCount := PropCount + 1;
End;
Try
MSIrecords := MSIView.Fetch;
Except
End;
End;
If PropCount < 1 Then
Begin
ListView3.Items.Add.Caption:='None Found';
ListView3.Enabled:=False;
End;
end;
Procedure TForm1.UpdateRegistryList(FName: String);
Var MSIobj, MSIdb, MSIView, MSIrecords: Variant;
PropCount: Integer;
root: Integer;
key, name, value: String;
begin
MSIobj := CreateOLEObject('WindowsInstaller.Installer');
MSIdb := MSIobj.OpenDatabase(FName, 0); // 0 - msiOpenDatabaseModeReadOnly
MSIView := MSIdb.OpenView('SELECT * FROM Registry');
MSIView.Execute;
PropCount:=0;
MSIrecords := MSIView.Fetch;
While IDispatch(MSIrecords)<>Nil Do
Begin
root:=StrToInt(MSIrecords.StringData[2]);
key:='';
case root of
0: key:='HKEY_CLASSES_ROOT';
1: key:='HKEY_CURRENT_USER';
2: key:='HKEY_LOCAL_MACHINE';
3: key:='HKEY_USERS';
4: key:='HKEY_CURRENT_CONFIG'; { ??? }
end;
If key<>'' Then key:=key + '\' + MSIrecords.StringData[3]
Else key:='Root Match Not Found For #' + IntToStr(root);
name := MSIrecords.StringData[4];
value := MSIrecords.StringData[5];
If key <> '' Then
Begin
ListView4.Items.Add.Caption:=key;
ListView4.Items[PropCount].SubItems.Add(name);
ListView4.Items[PropCount].SubItems.Add(value);
PropCount := PropCount + 1;
End;
Try
MSIrecords := MSIView.Fetch;
Except
End;
End;
If PropCount < 1 Then
Begin
ListView4.Items.Add.Caption:='None Found';
ListView4.Enabled:=False;
End;
end;
procedure TForm1.ListView1Click(Sender: TObject);
Var I: Integer;
begin
Label1.Caption:=''; // v1.02
If ListView1.ItemIndex >= 0 Then // v1.02
Begin
For I:=1 To Length(propList) Do
If propList[I] = ListView1.Items[ListView1.ItemIndex].Caption Then Break;
Label1.Caption:=propListDesc[I];
End;
end;
procedure TForm1.ListView1ColumnClick(Sender: TObject;
Column: TListColumn);
begin
TListView(Sender).CustomSort(Nil, Column.Index);
SortDirect:=-SortDirect;
end;
procedure TForm1.ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer);
begin
If Data = 0 Then Compare:=SortDirect*CompareText(Item1.Caption, Item2.Caption)
Else Compare:=SortDirect*CompareText(Item1.SubItems.Strings[Data-1], Item2.SubItems.Strings[Data-1]);
end;
end.