
21.01.2014, 13:43
|
 |
Профессионал
|
|
Регистрация: 06.08.2012
Адрес: Кривой Рог
Сообщения: 1,791
Версия Delphi: Delphi 7, XE2
Репутация: 4415
|
|
Код:
type
TAuthItem = record
Computer, User: String;
end;
const
Auths: array[1..3]of TAuthItem = (
(Computer: 'N-1238'; User: 'Никита'),
(Computer: 'N-1256'; User: 'Сергей'),
(Computer: 'N-1110'; User: 'Николай')
);
var
Logon: TAuthItem;
Countdown: Integer = 60;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Logon.Computer := ReadComputerName;
for i := Low(Auths) to High(Auths) do
begin
if AnsiSameText(Logon.Computer, Auths[i].Computer) then
begin
Logon.User := Auths[i].User;
Break;
end;
end;
if Logon.User = '' then
begin
MessageDlg('Вы не имеете прав на пользование данной программой. '+
'Попробовать 1 минутную пробную версию', mtInformation, [mbOK], 0);
Timer1.Enabled := True;
end else
begin
Timer1.Enabled := False;
StatusBar1.Panels[0].Text := 'Сессия пользователя '+ Logon.User;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Logon.User <> '' then Exit;
Dec(Countdown);
if Countdown <= 0 then
begin
Application.Terminate;
end else
begin
StatusBar1.Panels[0].Text := Format('До закрытия осталось %d сек', [Countdown]);
end;
end;
|