unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, Calendar, ComCtrls, Buttons, ShellAPI, IniFiles;

type
  TAlexTimer = class(TForm)
    Timer1: TTimer;
    Timer2: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    Calendar1: TCalendar;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    StatusBar1: TStatusBar;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    OS: TLabel;
    Label12: TLabel;
    Memo1: TMemo;
    BitBtn4: TBitBtn;
    OpenDialog1: TOpenDialog;
    FontDialog1: TFontDialog;
    BitBtn5: TBitBtn;
    BitBtn2: TBitBtn;
    ColorDialog1: TColorDialog;
    Edit1: TEdit;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;


 
    procedure Timer2Timer(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  AlexTimer: TAlexTimer;
  n :longint;
  cr:string;
  ct: string;
 


implementation
uses Unit2; 
{$R *.dfm}


procedure TAlexTimer.Timer2Timer(Sender: TObject);
var
  MS: TMemoryStatus;
  Platform: string;
  BuildNumber: Integer;
  begin
Label1.Caption:='Текущее время: '+TimeToStr(Time);
Label2.Caption:='Текущая дата: '+DateToStr(Date);
Label3.Caption:='Размер диска C - '+IntToStr(DiskSize(3) div 1024)+' Килобайт';
Label4.Caption:='На диске C свободно: '+IntToStr(DiskFree(3) div 1024)+' Килобайт';
Label5.Caption:='Размер диска D - '+IntToStr(DiskSize(4) div 1024)+' Килобайт';
Label6.Caption:='На диске D свободно '+IntToStr(DiskFree(4) div 1024)+' Килобайт';
Label7.Caption:='ПРИВЕТ! ЭТО ПРОГРАММА ALEXTIMER 2.0';
Label8.Caption:=TimeToStr(Time)+'             ДАТА '+DateToStr(Date);
GlobalMemoryStatus(MS);
Label10.Caption :='На диске физической памяти, всего: '+ FormatFloat('#,###" KB"', MS.dwTotalPhys / 1024);
Label11.Caption :='Загрузка оперативной памяти: '+ Format('%d %%', [MS.dwMemoryLoad]);

  case Win32Platform of
    VER_PLATFORM_WIN32_WINDOWS:
      begin
        Platform := 'Windows 95';
        BuildNumber := Win32BuildNumber and $0000FFFF;
      end;
    VER_PLATFORM_WIN32_NT:
      begin
        Platform := 'Windows NT';
        BuildNumber := Win32BuildNumber;
      end;
      else
      begin
        Platform := 'Windows';
        BuildNumber := 0;
      end;
  end;
  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) or
    (Win32Platform = VER_PLATFORM_WIN32_NT) then
  begin
    if Win32CSDVersion = '' then
      OS.Caption := Format('%s %d.%d (Build %d)', [Platform, Win32MajorVersion,
        Win32MinorVersion, BuildNumber])
    else
      OS.Caption := Format('%s %d.%d (Build %d: %s)', [Platform, Win32MajorVersion,
        Win32MinorVersion, BuildNumber, Win32CSDVersion]);
  end
  else
    OS.Caption := Format('%s %d.%d', [Platform, Win32MajorVersion,
      Win32MinorVersion])
end;


procedure TAlexTimer.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
StatusBar1.Panels[0].Text:=IntToStr(X)+' '+IntToStr(Y);
end;

procedure TAlexTimer.BitBtn1Click(Sender: TObject);
begin
AboutBox.ShowModal;
end;

procedure TAlexTimer.BitBtn3Click(Sender: TObject);
begin
AlexTimer.Visible:=False;
end;

procedure TAlexTimer.BitBtn4Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TAlexTimer.BitBtn5Click(Sender: TObject);
begin
if FontDialog1.Execute then Memo1.Font:=FontDialog1.Font;
end;

procedure TAlexTimer.BitBtn2Click(Sender: TObject);
begin
if ColorDialog1.Execute then
Memo1.Color:=ColorDialog1.Color;

end;

procedure TAlexTimer.FormClose(Sender: TObject; var Action: TCloseAction);
var cfProg: TIniFile;
begin
cfProg:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'prog.ini');
cfProg.WriteString('USER', 'UserName', Edit1.Text);
cfProg.WriteInteger('START', 'CountStart', n+1);
cfProg.WriteString('START', 'LastDate', DateToStr(Date));
cfProg.WriteString('START', 'LastTime', TimeToStr(Time));
cfProg.Free;
end;

procedure TAlexTimer.FormCreate(Sender: TObject);
var cfProg: TIniFile;
begin
cfProg:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'prog.ini');
n:=cfProg.ReadInteger('START', 'CountStart', 0);
Label13.Caption:='Программа запущена '+IntToStr(n+1)+' раз(а)';
Edit1.Text:=cfProg.ReadString('USER', 'UserName', '');
cr:=cfProg.ReadString('START', 'LastDate', DateToStr(Date));
Label14.Caption:='Дата последнего запуска программы: '+DateToStr(Date);
ct:=cfProg.ReadString('START', 'LastTime', TimeToStr(Time));
Label16.Caption:='Время последнего запуска программы: '+TimeToStr(Time);
cfProg.Free;
end;

end.
