How can I emulate Ctrl Alt Del key press through my application? So that my application can invoke Ctrl Alt Del dialog.
I don't believe you can, the closest you can do is to invoke the screen saver.
I have to ask you a question before you head down this track: why do you want to do it? I personally would be very pissed off if an app decided to lock my system, that is something that only i should be able to do (needless to say i would uninstall that app immediately).
I asked you this because you are possibly trying to do the wrong thing, there is probably a far better option for you. There is only one type of application (that i can think of) that would require that functionality, and that is a kiosk type app that you would find on a machine that the general public access.
I have to ask you a question before you head down this track: why do you want to do it? I personally would be very pissed off if an app decided to lock my system, that is something that only i should be able to do (needless to say i would uninstall that app immediately).
I asked you this because you are possibly trying to do the wrong thing, there is probably a far better option for you. There is only one type of application (that i can think of) that would require that functionality, and that is a kiosk type app that you would find on a machine that the general public access.
IF you can't find how to invoke the dialog, you can of course just give the user options to do those same things. Rebooting/Shutting Down/Logging Off Windows is farily simple. As for invoking Task Manager, you'll have to research that one.
On a side note, I don't find this too potentially harmful as the orginal question was to ask how to invoke the dialog, not send events to the window. I can see how it may be helpful in an app. Also, if somebody wanted to do damage, this is a really queer way to do it. An app that abused this would be annoying at best.
I'm not sure about this, but you may also want to look into SendInput. Anyways, good luck.
On a side note, I don't find this too potentially harmful as the orginal question was to ask how to invoke the dialog, not send events to the window. I can see how it may be helpful in an app. Also, if somebody wanted to do damage, this is a really queer way to do it. An app that abused this would be annoying at best.
I'm not sure about this, but you may also want to look into SendInput. Anyways, good luck.
What about sending WM_KEYDOWN messages?
What about sending WM_KEYDOWN messages?
To what? The ctrl-alt-delete sequence doesn't get to any WndProc, it gets intercepted way before that.
adnan: try looking at the exports of msgina.dll, you may find something useful there ;) But be aware, this dll is undocumented, which means MS don't want you calling it directly. There may also be some functions in ntdll.dll that you would find useful.
this should work:
;press keys
CALL MapVirtualKeyA,VK_CONTROL,0
CALL keybd_event,VK_CONTROL,eax,0,0
CALL MapVirtualKeyA,VK_MENU,0
CALL keybd_event,VK_MENU,eax,0,0
CALL MapVirtualKeyA,VK_DELETE,0
CALL keybd_event,VK_DELETE,eax,0,0
;release keys
CALL keybd_event,VK_DELETE,0,KEYEVENTF_KEYUP,0
CALL keybd_event,VK_MENU,0,KEYEVENTF_KEYUP,0
CALL keybd_event,VK_CONTROL,0,KEYEVENTF_KEYUP,0
this should work:
;press keys
CALL MapVirtualKeyA,VK_CONTROL,0
CALL keybd_event,VK_CONTROL,eax,0,0
CALL MapVirtualKeyA,VK_MENU,0
CALL keybd_event,VK_MENU,eax,0,0
CALL MapVirtualKeyA,VK_DELETE,0
CALL keybd_event,VK_DELETE,eax,0,0
;release keys
CALL keybd_event,VK_DELETE,0,KEYEVENTF_KEYUP,0
CALL keybd_event,VK_MENU,0,KEYEVENTF_KEYUP,0
CALL keybd_event,VK_CONTROL,0,KEYEVENTF_KEYUP,0
I already use this technique but it didn't work.
Thanks for your efforts,
Adnan
I don't believe you can, the closest you can do is to invoke the screen saver.
I have to ask you a question before you head down this track: why do you want to do it? I personally would be very pissed off if an app decided to lock my system, that is something that only i should be able to do (needless to say i would uninstall that app immediately).
I asked you this because you are possibly trying to do the wrong thing, there is probably a far better option for you. There is only one type of application (that i can think of) that would require that functionality, and that is a kiosk type app that you would find on a machine that the general public access.
__________________
sluggy
Sluggy!
I need this functionality to do the same thing as PC Anywhere & other applications do. In which when you send Ctrl Alt Del through menu option from Client to host. Host application, after getting this message from client, emulates this message on host.
I think now there shouldn't be no more confusion on this issue.
Adnan
I have to ask you a question before you head down this track: why do you want to do it? I personally would be very pissed off if an app decided to lock my system, that is something that only i should be able to do (needless to say i would uninstall that app immediately).
I asked you this because you are possibly trying to do the wrong thing, there is probably a far better option for you. There is only one type of application (that i can think of) that would require that functionality, and that is a kiosk type app that you would find on a machine that the general public access.
__________________
sluggy
Sluggy!
I need this functionality to do the same thing as PC Anywhere & other applications do. In which when you send Ctrl Alt Del through menu option from Client to host. Host application, after getting this message from client, emulates this message on host.
I think now there shouldn't be no more confusion on this issue.
Adnan
I already use this technique but it didn't work.
Thanks for your efforts,
Adnan
mh, it actually only works if the program is run from a cmd prompt. don't ask me why.
I need this functionality to do the same thing as PC Anywhere & other applications do
That is a fair reason :) I had to ask that question, because in another message board i frequent, there is always a lot of newbies coming through asking how to intercept that key sequence, and they always ask for totally the wrong reason.
I am not sure how PC Anywhere does it. However, there is another (and far better) app called VNC which does the same thing (it is freeware), and i believe the source code may be available for it. Failing that, i would set up PC Anywhere or VNC, and also run APImon on the client pc, and track what API calls are made when you send the ctrl-alt-del through. Look in particular for any calls to msgina.dll. Of course, once you have worked it out, you have to tell us what functions are used ;)