Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 6

Chapter 04 - Project WinVersion

Project Structure

WinVersion.dpr
program WinVersion;

uses
  Forms,
  WvForm in 'WvForm.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
WvForm.pas
unit WvForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    btnVersion: TButton;
    btnPlatform: TButton;
    procedure btnVersionClick(Sender: TObject);
    procedure btnPlatformClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.btnVersionClick(Sender: TObject);
begin
  ShowMessage ('Running on Windows: ' +
    IntToStr (Win32MajorVersion) + '.' +
    IntToStr (Win32MinorVersion) + ' (Build ' +
    IntToStr (Win32BuildNumber) + ') ' + #10#13+
   'Update: ' + Win32CSDVersion)
end;

procedure TForm1.btnPlatformClick(Sender: TObject);
begin
  case Win32Platform of
    VER_PLATFORM_WIN32_WINDOWS: ShowMessage ('Windows 9x');
    VER_PLATFORM_WIN32_NT: ShowMessage ('Windows NT');
  end;
end;

end.
WvForm.dfm
object Form1: TForm1
  Left = 195
  Top = 105
  Width = 216
  Height = 146
  Caption = 'WinVersion'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object btnVersion: TButton
    Left = 32
    Top = 24
    Width = 129
    Height = 25
    Caption = 'Windows version'
    TabOrder = 0
    OnClick = btnVersionClick
  end
  object btnPlatform: TButton
    Left = 32
    Top = 64
    Width = 129
    Height = 25
    Caption = 'Platform'
    TabOrder = 1
    OnClick = btnPlatformClick
  end
end