home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / Runimage / Delphi50 / Demos / Coolstuf / about.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  2.1 KB  |  101 lines

  1. unit About;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls;
  8.  
  9. type
  10.   TAboutBox = class(TForm)
  11.     OKButton: TButton;
  12.     Copyright: TLabel;
  13.     Bevel1: TBevel;
  14.     SKUName: TLabel;
  15.     Version: TLabel;
  16.     Image2: TImage;
  17.     PhysMem: TLabel;
  18.     OS: TLabel;
  19.     Label3: TLabel;
  20.     Image1: TImage;
  21.     procedure FormCreate(Sender: TObject);
  22.   private
  23.     procedure GetOSInfo;
  24.     procedure InitializeCaptions;
  25.   end;
  26.  
  27. procedure ShowAboutBox;
  28.  
  29. implementation
  30.  
  31. uses ShellAPI;
  32.  
  33. {$R *.DFM}
  34.  
  35. procedure ShowAboutBox;
  36. begin
  37.   with TAboutBox.Create(Application) do
  38.     try
  39.       ShowModal;
  40.     finally
  41.       Free;
  42.     end;
  43. end;
  44.  
  45. procedure TAboutBox.GetOSInfo;
  46. var
  47.   Platform: string;
  48.   BuildNumber: Integer;
  49. begin
  50.   case Win32Platform of
  51.     VER_PLATFORM_WIN32_WINDOWS:
  52.       begin
  53.         Platform := 'Windows 95';
  54.         BuildNumber := Win32BuildNumber and $0000FFFF;
  55.       end;
  56.     VER_PLATFORM_WIN32_NT:
  57.       begin
  58.         Platform := 'Windows NT';
  59.         BuildNumber := Win32BuildNumber;
  60.       end;
  61.       else
  62.       begin
  63.         Platform := 'Windows';
  64.         BuildNumber := 0;
  65.       end;
  66.   end;
  67.   if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) or
  68.     (Win32Platform = VER_PLATFORM_WIN32_NT) then
  69.   begin
  70.     if Win32CSDVersion = '' then
  71.       OS.Caption := Format('%s %d.%d (Build %d)', [Platform, Win32MajorVersion,
  72.         Win32MinorVersion, BuildNumber])
  73.     else
  74.       OS.Caption := Format('%s %d.%d (Build %d: %s)', [Platform, Win32MajorVersion,
  75.         Win32MinorVersion, BuildNumber, Win32CSDVersion]);
  76.   end
  77.   else
  78.     OS.Caption := Format('%s %d.%d', [Platform, Win32MajorVersion,
  79.       Win32MinorVersion])
  80. end;
  81.  
  82. procedure TAboutBox.InitializeCaptions;
  83. var
  84.   MS: TMemoryStatus;
  85. begin
  86.   GetOSInfo;
  87.   MS.dwLength := SizeOf(TMemoryStatus);
  88.   GlobalMemoryStatus(MS);
  89.   PhysMem.Caption := FormatFloat('#,###" KB"', MS.dwTotalPhys div 1024);
  90. end;
  91.  
  92. procedure TAboutBox.FormCreate(Sender: TObject);
  93. begin
  94.   InitializeCaptions;
  95.   with Image2.Picture.Bitmap do
  96.     Handle := CreateGrayMappedBmp(Handle);
  97. end;
  98.  
  99. end.
  100.  
  101.