我的应用程序已经有了一个模式多年,客户可以“禁用对操作系统的访问”。显然,这种功能违反了潮流(至少在Windows方面如此),但是有些安装中,我的应用程序是唯一应该对机器操作员可见的程序,在这种情况下,这样的功能非常有用。
我使用的技巧由几个“层”构成:
- 隐藏任务栏和按钮。
- 禁用任务切换。
- 禁用我的主窗体系统图标。
为了禁用任务栏,我使用了:
// Get a handle to the taskbar and its button..
Taskbar := FindWindow('Shell_TrayWnd', Nil);
StartButton := FindWindow('Button', Nil);
// Hide the taskbar and button
if Taskbar <> 0 then
ShowWindow( Taskbar, SW_HIDE );
if StartButton <> 0 then
ShowWindow( StartButton, SW_HIDE );
// Set the work area to the whole screen
R := Rect( 0,0,Screen.Width,Screen.Height );
SystemParametersInfo(
SPI_SETWORKAREA,
0,
@R,
0 );
这在W7上运行良好,看起来依然可用。几年前,研究如何禁用任务切换时,唯一的技术是“假装”你的应用程序是屏幕保护程序(除了像将应用程序重命名为“explorer.exe”并引导到它之类的可怕事情):
procedure EnableTaskSwitching( AState : boolean );
// Enables / disables task switching
begin
SystemParametersInfo(
SPI_SCREENSAVERRUNNING,
Cardinal( not AState),
nil,
0 );
end;
毫不奇怪的是这种方法在Windows 7中似乎没有效果(我认为它在XP等其他版本中有效)。 有没有人知道另一种更好的方法来禁用/启用Alt-Tab(和其他特殊的Windows键)?