| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; procedure FormCreate(Sender: TObject); private { Private declarations } procedure Idle(Sender: TObject; var Done: Boolean); public { Public declarations } end;
var Form1: TForm1; bLocked: Boolean = False;
const MAX_MINUT_IDLE = 1; // кол-во времени по истечении (в минутах) // которого прога будет блокироваться
MAX_IDLE = 1000 * 60 * MAX_MINUT_IDLE;
implementation
{$R *.dfm}
function LastInput: DWord; var LInput: TLastInputInfo; begin LInput.cbSize := SizeOf(TLastInputInfo); GetLastInputInfo(LInput); Result := GetTickCount - LInput.dwTime; end;
procedure TForm1.FormCreate(Sender: TObject); begin Application.OnIdle := Idle; end;
procedure TForm1.Idle(Sender: TObject; var Done: Boolean); begin if (LastInput >= MAX_IDLE) and not bLocked then begin bLocked := True; { lock program } Done := True; end; end; |
Добавлено @ 17:36 DemoCode Блин, опередил таки  |