unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject); begin LockWorkStation; end;end. 只在NT下有用
是吗,可是我在我们公司的所有计算机上都试过了都报告“无法定位程序输入点LockWorkStation于user32.dll上,我想该项功能已经被新的NT Service Park 屏蔽了
我说错了。。 只能在2000上用了 Requires Windows 2000 or later; Win9x/ME: Not supported
我有一个很笨的想法,能不能用键盘模拟ctrl+alt+del再加回车。。就锁定了。。呵呵
找到锁NT 4的方法 了Windows 2000 As stated in the following Microsoft Knowledge Base article, if you start a screen saver manually from the command line by using only the screen saver's file name, the screen saver does not require a password and the workstation is not locked: Q228160 Screen Saver Is Not Password Protected If Started Manually To lock a workstation programmatically, you can use the Win32 LockWorkStation function. You can call this function from the command line by using the Run32dll interface. To lock a workstation from the command line, use the following command: rundll32 user32.dll,LockWorkStation Note that this command is white space sensitive and case sensitive. This call was introduced in Windows 2000 and is not supported in earlier versions of Windows. Windows NT 4.0 There is no solution to lock a Windows NT 4.0-based workstation from the command line. You can, however, achieve a similar effect with some additional configuration.In Windows NT 4.0, you can use the SendMessage call to send a SC_SCREENSAVE message to the topmost window, which locks the workstation if the current user has a screen saver configured and the screen saver is configured to require a password.To ensure that a screen saver is configured, you can create registry entries. Run a registry (.reg) file that adds the following entries from the command line: HKCU\Control Panel\Desktop\ScreenSaveActive = 1 HKCU\Control Panel\Desktop\ScreenSaverIsSecure = 1 HKCU\Control Panel\Desktop\ScreenSaveTimeout = timeout in seconds HKCU\Control Panel\Desktop\SCRNSAVE.EXE = %SystemRoot%\System32\Appropriate screen saver.scr Some screen savers require additional parameters in HKCU\Control Panel\Screen Saver.screen saver name as well.After you create these registry entries, the following call invokes the screen saver: SendMessage(HWND_TOPMOST, WM_SYSCOMMAND, SC_SCREENSAVE, 0) You must write and compile a short program (.exe file) that contains this call. You can then call your program from the command line to activate the screen saver. Because the ScreenSaverIsSecure value in the registry has been set to 1, this has the effect of locking the workstation.
Dummy : integer;
begin
Dummy := 0;
{屏蔽ALT-TAB}
SystemParametersInfo( SPI_SETFASTTASKSWITCH, 1, @Dummy, 0);
{屏蔽 CTRL-ALT-DEL}
SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @Dummy, 0);
end.
begin
EnableWindow(handle,true) ;
showwindow(form1.handle,SW_SHOW);
SizeofHnd :=MinimizeWindowOnDesktop ; //将所有窗口最小化只显示桌面
EnableWindow(hTask,false) ; //锁住任务栏
EnableWindow(hDesktop,false) ;//锁住桌面
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @integer(1), 0);
end;
end;
经过这样处理,你只有重启PC否则你是没有办法再用电脑的
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
LockWorkStation;
end;end.
只在NT下有用
只能在2000上用了
Requires Windows 2000 or later; Win9x/ME: Not supported
As stated in the following Microsoft Knowledge Base article, if you start a screen saver manually from the command line by using only the screen saver's file name, the screen saver does not require a password and the workstation is not locked:
Q228160 Screen Saver Is Not Password Protected If Started Manually
To lock a workstation programmatically, you can use the Win32 LockWorkStation function. You can call this function from the command line by using the Run32dll interface. To lock a workstation from the command line, use the following command:
rundll32 user32.dll,LockWorkStation
Note that this command is white space sensitive and case sensitive. This call was introduced in Windows 2000 and is not supported in earlier versions of Windows.
Windows NT 4.0
There is no solution to lock a Windows NT 4.0-based workstation from the command line. You can, however, achieve a similar effect with some additional configuration.In Windows NT 4.0, you can use the SendMessage call to send a SC_SCREENSAVE message to the topmost window, which locks the workstation if the current user has a screen saver configured and the screen saver is configured to require a password.To ensure that a screen saver is configured, you can create registry entries. Run a registry (.reg) file that adds the following entries from the command line:
HKCU\Control Panel\Desktop\ScreenSaveActive = 1
HKCU\Control Panel\Desktop\ScreenSaverIsSecure = 1
HKCU\Control Panel\Desktop\ScreenSaveTimeout = timeout in seconds
HKCU\Control Panel\Desktop\SCRNSAVE.EXE = %SystemRoot%\System32\Appropriate screen saver.scr
Some screen savers require additional parameters in HKCU\Control Panel\Screen Saver.screen saver name as well.After you create these registry entries, the following call invokes the screen saver:
SendMessage(HWND_TOPMOST, WM_SYSCOMMAND, SC_SCREENSAVE, 0)
You must write and compile a short program (.exe file) that contains this call. You can then call your program from the command line to activate the screen saver. Because the ScreenSaverIsSecure value in the registry has been set to 1, this has the effect of locking the workstation.
气死我哒。