PDA

Click to See Complete Forum and Search --> : Programs in Close Program menu


Wynd
Sep 20th, 2001, 06:00 PM
Is it possible to, when the user attempts to close my program using ctrl+alt+delete, have it stay open? If it is, is there also a way to disable it?

crptcblade
Sep 20th, 2001, 06:06 PM
perhaps if you set a boolean and check if it is true when you catch the WM_DESTROY message?

I think that could work, but I am not sure.

:)

Wynd
Sep 20th, 2001, 06:17 PM
Yeah, that might work, but what about closing it after it's like that?

crptcblade
Sep 20th, 2001, 06:28 PM
Well, if you check a boolean in the WM_DESTROY code, you can set it to true if you click a button or something, and that will allow you to use the PostQuitMessage() function, otherwise, just return 0.

:)

Wynd
Sep 20th, 2001, 06:59 PM
Thanks, I tried that and it worked. I just have one more question. Can I do it from another program? (I can do it with the process viewer by killing it, but is there another way?)

CornedBee
Sep 23rd, 2001, 04:37 AM
hmmm, I don't see why you wanna do that, I mean the ctrl+alt+del is an emergency command and no program is supposed to ignore it.
But you can always kill any application with the TerminateProcess function, provided you get a handle to it. (process handle or instance handle)

Wynd
Sep 23rd, 2001, 12:16 PM
How can I get a handle to it? I don't see any function in MSDN except for GetCurrentProcess(), which doesn't seem like what I want. The application I am using this for is hidden, but it is visible in the Close Program box.

CornedBee
Sep 23rd, 2001, 12:29 PM
OpenProcess
This will require the process ID, that you can get by GetCurrentProcessId and save somewhere.

Maybe you can also use FindWindow to get the window of your application and GetWindowLong to retrieve the instance handle. Instance handles and pocess handles are interchangeable (I think)

Megatron
Sep 23rd, 2001, 02:39 PM
I remember reading somewhere that as part of Window's safety features, you can not simulate the pressing of ctrl+alt+del, nor can you prevent and App from being destroyed via ctrl+alt+del.

CornedBee
Sep 23rd, 2001, 03:11 PM
you can at least simulate it. PC Anywhere does it.