本文整理自网络,侵删。
delphi 代码unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end;//typedef struct tagLASTINPUTINFO { //UINT cbSize; // DWORD dwTime;// LASTINPUTINFO, *PLASTINPUTINFO;
type LASTINPUTINFO = record cbSize:UINT; dwTime:DWORD;end;var Form1: TForm1;
implementation
{$R *.dfm}
function GetInputAwayTime():DWORD;var lpi:TLastInputInfo;begin lpi.cbSize := sizeof(lpi); GetLastInputInfo(lpi); Result := Round((GetTickCount()-lpi.dwTime)/1000);end;procedure TForm1.Timer1Timer(Sender: TObject);begin Caption := IntToStr(GetInputAwayTime)end;
end.
vc代码DWORD GetInputAwayTime(){ LASTINPUTINFO lpi; lpi.cbSize = sizeof(lpi); GetLastInputInfo(&lpi); return DWORD((GetTickCount()-lpi.dwTime)/1000);}
相关阅读 >>
Delphi 自定义colorbox只显示指定颜色项目 colorbox显示中文颜色名称
更多相关阅读请进入《Delphi》频道 >>