怎么用程序实现Ctrl+Alt+Del三键同时按下的效果?

DryFisHH 2005-05-21 05:29:03
rt
...全文
390 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wshcdr 2005-05-23
  • 打赏
  • 举报
回复
偶这里不行

OpenDesktop

返回NULL
koko1998 2005-05-23
  • 打赏
  • 举报
回复
VC知识库文章 - WINDOWS NT-2000下如何屏蔽CTRL+ALT+DEL.htm
VC知识库文章 - Windows XP系统中如何屏蔽 Ctrl+Alt+Del、Alt+Tab以及Ctrl+Esc键序列.htm

在网上看看上面两篇文章,看看有没有帮助!
DryFisHH 2005-05-23
  • 打赏
  • 举报
回复
呵呵,我找到答案了,贴出来,给那些有着相同问题的人看。


注意
:OpenDesktop("Winlogon", ......)本身需要LocalSystem权限,否则会返回“拒绝访问”错误(错误代码5)。

/*********************************************************************
// COMPANY : RABCO SYSTEM
// AUTHOR : SUKANTA KUMAR DASH
// DATE : 21.01.2003
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2003 by Sukanta Kumar Dash ,Rabco systems , India
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// sukantakumar@rediffmail.com
/////////////////////////////////////////////////////////////////////////////
*/
#include "windows.h"
BOOL simulateAltControlDel();
void main()
{
simulateAltControlDel();
}
BOOL simulateAltControlDel()
{
HDESK hdeskCurrent;
HDESK hdesk;
HWINSTA hwinstaCurrent;
HWINSTA hwinsta;
//
// Save the current Window station
//
hwinstaCurrent = GetProcessWindowStation();
if (hwinstaCurrent == NULL)
return FALSE;
//
// Save the current desktop
//
hdeskCurrent = GetThreadDesktop(GetCurrentThreadId());
if (hdeskCurrent == NULL)
return FALSE;
//
// Obtain a handle to WinSta0 - service must be running
// in the LocalSystem account
//
hwinsta = OpenWindowStation("winsta0", FALSE,
WINSTA_ACCESSCLIPBOARD |
WINSTA_ACCESSGLOBALATOMS |
WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE |
WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES |
WINSTA_READSCREEN |
WINSTA_WRITEATTRIBUTES);
if (hwinsta == NULL)
return FALSE;
//
// Set the windowstation to be winsta0
//
if (!SetProcessWindowStation(hwinsta))
return FALSE;

//
// Get the default desktop on winsta0
//
hdesk = OpenDesktop("Winlogon", 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS);
if (hdesk == NULL)
return FALSE;

//
// Set the desktop to be "default"
//
if (!SetThreadDesktop(hdesk))
return FALSE;
PostMessage(HWND_BROADCAST,WM_HOTKEY,0,MAKELPARAM(MOD_ALT|MOD_CONTROL,VK_DELETE));


//
// Reset the Window station and desktop
//
if (!SetProcessWindowStation(hwinstaCurrent))
return FALSE;

if (!SetThreadDesktop(hdeskCurrent))
return FALSE;

//
// Close the windowstation and desktop handles
//
if (!CloseWindowStation(hwinsta))
return FALSE;
if (!CloseDesktop(hdesk))
return FALSE;
return TRUE;
}
luolovegui 2005-05-21
  • 打赏
  • 举报
回复
同意:Ctrl+Alt+Del 是不能通过代码模拟出来的, 这是WINDOWS 专有的.

DryFisHH 2005-05-21
  • 打赏
  • 举报
回复
那么,象一些远程控制软件利用其他的组合键,比如ctrl+alt+F12,来使远程产生Ctrl+Alt+Del 事件,是怎么实现的?

我模拟三键相继按下的事件 key_event(VK_CONTROL, ..);key_event(VK_MENU, ..);key_event(VK_DELETE, ..),这样好像不行,这又是为何?
OnlyHappy 2005-05-21
  • 打赏
  • 举报
回复
不会吧.我想不能
truewill 2005-05-21
  • 打赏
  • 举报
回复
似乎很多远程控制的软件都能发这个功能的哦
fireseed 2005-05-21
  • 打赏
  • 举报
回复
int WlxLoggedOnSAS( pWlxContext,WLX_SAS_TYPE_CTRL_ALT_DEL, NULL);
xyw2278 2005-05-21
  • 打赏
  • 举报
回复
大概不行
jerry 2005-05-21
  • 打赏
  • 举报
回复
Ctrl+Alt+Del 是不能通过代码模拟出来的, 这是WINDOWS 专有的.
fireseed 2005-05-21
  • 打赏
  • 举报
回复
sendmessage keydown

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧