본문 바로가기
Delphi Tip/하드웨어

델파이 동작 없을 시 자동 로그아웃

by MonoSoft 2021. 8. 23.
728x90
반응형

델파이 동작 없을 시 자동 로그아웃

 

var

Form1: TForm1;

tm: integer;

Crs: TPoint;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);

var

message: TWMKey;

begin

if Msg.message = WM_MOUSEMOVE then

begin

if (Abs(LOWORD(Msg.lParam) - crs.x) > 20) or

(Abs(HIWORD(Msg.lParam) - crs.y) > 20) then // 마우스 움직임 감시

tm := 0;

end

else

if (Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP) then // Key 감시

tm := 0;

end;

 

procedure TMainForm.FormShow(Sender: TObject);

begin

GetCursorPos(crs);

end;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

Application.OnMessage := AppMessage;

Timer1.Enabled := True;

end;

 

procedure TForm1.Timer1Timer(Sender: TObject);

begin

tm := tm + 10000;

if tm >= 10 * (60 * 1000) then // 10분이라면 

begin

Timer1.Enabled := False;

// 종료 또는 로그아웃 작업

Exit;

end;

end;

 

728x90
반응형

댓글