有没有在一段时间内没有用电脑就自动锁定软件的控件?
有没有在一段时间内没有用电脑就自动锁定软件的控件?
当用户再次使用时弹出输入密码的对话框.
问题点数:50、回复次数:27Top
1 楼vividw(vividw)回复于 2006-08-10 16:20:31 得分 0
屏幕保护就可以了 ...Top
2 楼wudi_1982(向伴水学习|胃出血,住院中)回复于 2006-08-10 16:23:47 得分 0
自动锁定软件,锁定那个软件。。如果锁定你自己的软件,在onmessage中判断一下wm_keydown以及鼠标运动的消息,自己写一个就可以了啊。Top
3 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 16:26:04 得分 25
3秒种不动鼠标键盘看看效果。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function BlockInput(fFreezeInput : boolean):DWord; stdcall; external 'user32.DLL';
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
vLastInputInfo: TLastInputInfo;
begin
vLastInputInfo.cbSize := SizeOf(vLastInputInfo);
GetLastInputInfo(vLastInputInfo);
if GetTickCount - vLastInputInfo.dwTime > 3000 then
begin
timer1.Enabled:= false;
BlockInput(True);
showmessage('超过3秒,已锁定!');
end;
end;
end.
Top
4 楼dejoy(燕青)回复于 2006-08-10 16:26:10 得分 0
呵呵 当然是锁定我的软件,如果用户离开了一会儿,别人动了他的数据那可不妙Top
5 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 16:27:24 得分 0
这个锁定只是演示,具体自己来处理就可以了Top
6 楼dejoy(燕青)回复于 2006-08-10 16:38:06 得分 0
xixuemao(从哪里跌倒就要从哪里抬出去)
兄弟,你这招太狠了,不单是锁定了软件,而是锁定了整个系统
刚才我运行你的demo,结果给锁死了,没办法只好强行关机重启,还好我已经保存了数据~~
这应该不是我想要的效果吧Top
7 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 16:39:56 得分 0
晕啊,你按一下热起键就解开了啊??汗Top
8 楼wudi_1982(向伴水学习|胃出血,住院中)回复于 2006-08-10 16:40:27 得分 0
xixuemao的方法可行的。。你也可以用我给你说的方法,在application的onmessage中截获鼠标和键盘消息,如果N久没动,就弹出对话框锁定。Top
9 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 16:41:06 得分 0
只是提供一个方法,你把里面的BlockInput(True);换成软件的注销不就可以了吗?Top
10 楼dejoy(燕青)回复于 2006-08-10 16:51:04 得分 0
我整个键盘都按过来了还是解不开才重启的,你说的是那个热键?
BlockInput是什么用途?好像会锁定整个系统,我只要锁定我的程序就行了Top
11 楼wudi_1982(向伴水学习|胃出血,住院中)回复于 2006-08-10 16:55:39 得分 25
功能是阻塞键盘鼠标输入
// Import BlockInput function form user32.dll:
// BlockInput Funktion von user32.dll importieren:
function BlockInput (fBlockInput : boolean) : DWord; stdcall; external 'user32.DLL';
{block input/ blockieren}
procedure TForm1.Button1Click(Sender: TObject);
begin
BlockInput(true);
end;
{unblock input / Blockierung aufheben}
procedure TForm1.Button2Click(Sender: TObject);
begin
BlockInput(false);
end;
Note: Requires Windows 98/2000 or later.
You can unblock input by pressing
CTRL+ALT+DEL
Top
12 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 16:58:37 得分 0
按Ctrl+Alt+Del三个键就会解开
我知道你是要冻结你的程序,我只是给你一个判断鼠标键盘没有操作的方法,你把
BlockInput(True);删掉,换成自己的处理不就可以了吗?比如超过一定时间就把自己的程序注销掉,让用户重新登录等等...Top
13 楼postren(小虫【宝宝出生,真忙】)回复于 2006-08-10 17:18:11 得分 0
不错Top
14 楼postren(小虫【宝宝出生,真忙】)回复于 2006-08-10 17:18:18 得分 0
收藏先Top
15 楼dejoy(燕青)回复于 2006-08-10 17:19:06 得分 0
明白了,多谢!
但怎么才知道用户再次使用程序?在那儿判断?Top
16 楼dejoy(燕青)回复于 2006-08-10 17:20:10 得分 0
xixuemao 兄的代码是锁定时的代码,但不知解锁时的代码如何?Top
17 楼wudi_1982(向伴水学习|胃出血,住院中)回复于 2006-08-10 17:23:07 得分 0
根据鼠标或者键盘的消息。。
举例如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, AppEvnts;
type
TForm1 = class(TForm)
Timer1: TTimer;
ApplicationEvents1: TApplicationEvents;
procedure Timer1Timer(Sender: TObject);
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
vLastInputInfo: TLastInputInfo;
begin
vLastInputInfo.cbSize := SizeOf(vLastInputInfo);
GetLastInputInfo(vLastInputInfo);
if GetTickCount - vLastInputInfo.dwTime > 3000 then
begin
timer1.Enabled:= false;
showmessage('超过3秒,已锁定!');
end;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (msg.message = WM_KEYDOWN) or (msg.message = WM_MOUSEMOVE) or (Msg.message = WM_MOUSEACTIVATE) then
if not Timer1.Enabled then timer1.Enabled := true;
end;
end.
Top
18 楼dejoy(燕青)回复于 2006-08-10 17:29:16 得分 0
多谢!
ApplicationEvents1应该就是用来接收用户的再次使用电脑的消息吧,在TForm1.ApplicationEvents1Message弹出输入密码对话框,对吧?Top
19 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 17:30:22 得分 0
不用处理鼠标键盘消息,只要timer一直enable,只要鼠标键盘有操作它会自动重新计时。
procedure TForm1.Timer1Timer(Sender: TObject);
var
vLastInputInfo: TLastInputInfo;
begin
vLastInputInfo.cbSize := SizeOf(vLastInputInfo);
GetLastInputInfo(vLastInputInfo);
if GetTickCount - vLastInputInfo.dwTime > 3000 then
begin
//我刚才showmessage演示一下,所以才使用timer.enable:= false,把他们都去掉直接
//在这里放注销用户,重新登录的代码,就可以了。不要关闭timer
end;
end;Top
20 楼wudi_1982(向伴水学习|胃出血,住院中)回复于 2006-08-10 17:35:08 得分 0
ApplicationEvents1应该就是用来接收用户的再次使用电脑的消息吧,在TForm1.ApplicationEvents1Message弹出输入密码对话框,对吧?
可以这么做。Top
21 楼dejoy(燕青)回复于 2006-08-10 17:38:03 得分 0
多谢两位两星上将,两种不同的思路,不过殊途同归.
据两位了解,有没有将这个功能封装的控件,就像TApplicationEvents这样的Top
22 楼wudi_1982(向伴水学习|胃出血,住院中)回复于 2006-08-10 17:41:19 得分 0
好像木有,因为可以封装计时的这些东西,但不好封装锁定的东西,因为开发者很难知道你要锁定后的效果是什么样子的,例如弹出一个框框,要求输入密码(那密码是从数据库读取还是从本地的文本文件)。Top
23 楼xixuemao(钱不是问题,问题是没钱)回复于 2006-08-10 17:43:34 得分 0
汗,你还是没理解这段代码的意义,不用ApplicationEvents处理鼠标键盘消息
GetLastInputInfo(vLastInputInfo);已经处理了,只要一直开着timer就可以了。Top
24 楼comerliang(天地良心)(性欲被自己倒分倒没了,以后再也不敢倒分了,想倒分的兄弟看看我的下场吧,男人没了性欲真不爽)回复于 2006-08-11 08:28:31 得分 0
markTop
25 楼Radar2006(中华英雄)回复于 2006-08-11 10:37:00 得分 0
upTop
26 楼xiaotao2004(郁闷中...)回复于 2006-08-11 10:46:54 得分 0
学习Top
27 楼songlife33(美女,偶们结婚吧)回复于 2006-08-11 10:50:02 得分 0
先hook键盘和鼠标,然后设置定时器,然后锁控件Top




