可以使用 Delphi 在 W7 中禁用任务切换键盘快捷键吗?
我的应用程序多年来一直有一种模式,客户可以“禁用对操作系统的访问”。显然,这个功能违背了原则(至少就 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;
毫不奇怪这似乎在 W7 中没有效果(我认为它在 XP 等中有效)。 有谁知道另一种更好的方法来启用/禁用 Alt-Tab (和其他特殊的 Windows 键)工作?
MY application has had a mode for years where the customer can 'disable access to the OS'. Obviously this feature goes against the grain (at least as far as Windows is concerned) but there are installations where my App is the only program that should ever be visibile to a machine operator amd in this case such a feature is useful.
The technigue I used was built from several 'layers':
- Hide the taskbar and button.
- Disable task-switching.
- Disable my main form system icons.
To disable the taskbar I used:
// 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 );
This worked well and still seems fine on W7.
Researching how to disable task-switching some years ago turned up the only technique of 'pretending' that your App is a screen saver (other than terrible things like renaming your app to 'explorer.exe' and booting into it etc):
procedure EnableTaskSwitching( AState : boolean );
// Enables / disables task switching
begin
SystemParametersInfo(
SPI_SCREENSAVERRUNNING,
Cardinal( not AState),
nil,
0 );
end;
Not surprisingly this seems to have no effect in W7 (I think it works in XP etc).
Does anyone know of another, better, way of enabling / disabling Alt-Tab (and other special windows keys) from working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果找到解决方案:
这会禁用(如您所见!)
If found a solution:
This disables (as you can see!)
正如大卫所指出的,这称为“信息亭模式”。几篇好文章(第 1 部分 和 第 2 部分)可在 About.com 上找到。
As David has pointed out, this is called "Kiosk Mode". A couple of good articles (part 1 and part 2) can be found on About.com.
有 Windows Embedded Standard 7您可以以具有真正的信息亭模式的方式进行打包。
There is Windows Embedded Standard 7 that you can package in a way that has a true kiosk mode.
dWinLock也提供了解决方案。 IIRC,他们安装了一个可以停止 Ctrl+Alt+Del 的服务。
dWinLock also provides a solution. IIRC, they install a service that can stop Ctrl+Alt+Del.