从我的应用程序发送消息 Ctrl+Alt+Del

2022-01-12 00:00:00 windows winapi mfc

我想在 MFC 中编写一个小实用程序,它将 Ctrl+Alt+Del 消息发送到操作系统.任何人都可以帮助我如何实现这一目标?我试过了:

I want to write a small utility in MFC which sends the Ctrl+Alt+Del message to OS. Can any one help me how do I achieve this? I tried:

::PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG( MOD_CONTROL | MOD_ALT, VK_DELETE));

但这不起作用.

我想发送 Ctrl+Alt+Del 不调用 TaskMgr.exe.此外,它适用于我的本地操作系统(Windows XP Service Pack 2).基本上我想使用这个应用程序来锁定我的机器并安排一些操作以及锁定.

I want to send Ctrl+Alt+Del not to invoke TaskMgr.exe. Also, it is for my local OS (Windows XP Service pack 2). Basically I want to use this application to lock my machine and schedule some actions along with locking.

推荐答案

这不是你可以模拟的击键.它被称为安全注意序列".以下是从远程桌面(XP+ 解决方案)调用它的方法:

This is not a keystroke you can simulate. It's called the "Secure Attention Sequence". Here's how to invoke it FROM A REMOTE DESKTOP (XP+ solution):

include <shldisp.h>

IShellDispatch4 *pShell;

CoInitialize(NULL);

HRESULT hr = CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC_SERVER,
IID_IShellDispatch, (void**)&pShell);

if(SUCCEEDED(hr))
pShell->WindowsSecurity();

CoUninitialize();

从本地桌面调用它的唯一解决方案是使用 SASLib.这不是公开的.写信给 saslib@microsoft.com 以请求它.

The only solution to invoke it from the local desktop is to use SASLib. It's not public. Write a note to saslib@microsoft.com to request it.

等等!你想锁定机器?只需调用 LockWorkStation()!单击链接以获取有关头文件、lib 文件等所有其他详细信息的更多信息.

Wait! You want to lock the machine? Just call LockWorkStation()! Click the link for more info about header file, lib file et all other details.

相关文章