Click here to Skip to main content
15,884,099 members
Articles / Programming Languages / C++
Article

Simulate Alt+Control+delete

Rate me:
Please Sign up or sign in to vote.
2.43/5 (14 votes)
20 Jan 2003 190.9K   3.8K   28   51
How to Simulate Alt+Control+delete

Introduction

Simulate alt control delete command in windows nt, 2k, xp.
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));

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: Can't run in win200, why? Pin
DavidR_r2-Jul-04 9:23
DavidR_r2-Jul-04 9:23 
GeneralSetThreadDesktop Pin
paulashford25-Feb-04 23:56
paulashford25-Feb-04 23:56 
GeneralRe: SetThreadDesktop Pin
planets23-Mar-04 6:17
planets23-Mar-04 6:17 
Questionwhat about to deactivate these keys? Pin
Dr.Lutfi16-Aug-03 3:21
sussDr.Lutfi16-Aug-03 3:21 
QuestionAnd what about simulating ALT + TAB ? Pin
JL00218-Jul-03 7:05
JL00218-Jul-03 7:05 
AnswerRe: And what about simulating ALT + TAB ? Pin
Sukanta Kumar Dash18-Jul-03 19:23
Sukanta Kumar Dash18-Jul-03 19:23 
QuestionWhy not use ExitWindowsEx()? Pin
vcplusplus23-Jan-03 3:27
vcplusplus23-Jan-03 3:27 
AnswerRe: Why not use ExitWindowsEx()? Pin
Member 191646516-May-05 23:30
Member 191646516-May-05 23:30 
Because we need NOT to reboot, but to simulate CTRL+ALT+DEL, as we pressed it.
GeneralNo simulation occurred Pin
Golden Lee22-Jan-03 22:50
Golden Lee22-Jan-03 22:50 
GeneralRe: No simulation occurred Pin
Sukanta Kumar Dash26-Jan-03 22:51
Sukanta Kumar Dash26-Jan-03 22:51 
GeneralRe: No simulation occurred Pin
Artem Moroz29-Jan-03 12:04
Artem Moroz29-Jan-03 12:04 
GeneralGood job!!! Pin
jedyking22-Jan-03 6:40
jedyking22-Jan-03 6:40 
GeneralOpenDesktop("Winlogon"... failed Pin
Jon22-Jan-03 3:11
Jon22-Jan-03 3:11 
GeneralNon-code way could be done in a shortcut etc.. Pin
RobJones21-Jan-03 7:29
RobJones21-Jan-03 7:29 
GeneralRe: Non-code way could be done in a shortcut etc.. Pin
Sukanta Kumar Dash21-Jan-03 18:01
Sukanta Kumar Dash21-Jan-03 18:01 
GeneralRe: Non-code way could be done in a shortcut etc.. Pin
Fad B4-Sep-03 6:44
Fad B4-Sep-03 6:44 
GeneralRe: Non-code way could be done in a shortcut etc.. Pin
RobJones4-Sep-03 14:29
RobJones4-Sep-03 14:29 
GeneralRe: Non-code way could be done in a shortcut etc.. Pin
Fad B5-Sep-03 0:55
Fad B5-Sep-03 0:55 
GeneralGreat!! Pin
_Magnus_21-Jan-03 5:16
_Magnus_21-Jan-03 5:16 
GeneralComplete information Pin
Gabriel 221-Jan-03 2:08
Gabriel 221-Jan-03 2:08 
GeneralVery useful! Pin
Daniel Turini21-Jan-03 0:27
Daniel Turini21-Jan-03 0:27 
GeneralRe: Very useful! Pin
Anonymous21-Jan-03 0:41
Anonymous21-Jan-03 0:41 
GeneralRe: Very useful! Pin
Daniel Turini21-Jan-03 0:58
Daniel Turini21-Jan-03 0:58 
GeneralRe: Very useful! Pin
Garth J Lancaster21-Jan-03 10:14
professionalGarth J Lancaster21-Jan-03 10:14 
GeneralRe: Very useful! Pin
Member 191646517-May-05 0:00
Member 191646517-May-05 0:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.