Don't close the program?

What code would I add to a program to make it so that the X in the top-right corner does not work, and is EDIT: I don't need it invisible to task manager.
Last edited on
is invisible to task manager?
That's not possible, except by doing some very distasteful things.
helios wrote:
except by doing some very distasteful things

Like globally hooking the EnumProcesses function?
Like loading a kernel driver that manually removes a node from the process list.
That far? Won't this stop the execution of the process?
Nope. But the system will crash if the process terminates while not listed. Probably something to do with resource deallocation.
But... how will the kernel know that it must allocate time slices to that particular process if you remove it from the process list? (bear with me a little, I just started learning that stuff)
AFAIK, that particular list doesn't do anything other than list running process for user level applications. The kernel doesn't keep internal state there, only a reflection of internal state.

EDIT: Oh, I just thought of something. You can't prevent a process from being killed, but you can "resuscitate" it if that happens. I call it "the Robin Hood design".
http://catb.org/jargon/html/meaning-of-hack.html (third story)
Last edited on
hahaha, that was a nice one! :D
looks like somebody's making a program thats intending to f*** up someones computer. ie. not let you close it while it works away at f'ing up the computer. nasty piece of work.
(i tried so hard not to swear. i'd rather not get reported)

Also may i ask what does your program do cos i can't think of any other reason why you wouldn't want the program to be closed.
Last edited on
i tried so hard not to swear


I think most of us here don't really care.

Anyway...I would have to agree.
the last forum i swore on some (probably fat no-life) reported me and i got banned in like 10 minutes. in other words, just being careful.
You know how on Word, Dev C++, and other stuff how it stops the program from closing so it can say "Are you sure you want to exit?" or something like that? That's kind of what I want. (btw, I am not trying to screw up someone's computer. they could just turn it off if I was doing that.) Is it like system ("PAUSE") or something like that???
Oh, that's as easy as handling the WM_CLOSE message in your main message loop:

http://msdn.microsoft.com/en-us/library/ms632617%28VS.85%29.aspx

EDIT: That is if you're doing this in a window application... I think you can do it in the console too by hooking the GetMessage function:

http://msdn.microsoft.com/en-us/library/ms644959%28VS.85%29.aspx#whgetmessagehook
Last edited on
It's a bit suspicious since it could be used by malicious coders but there are many valid reasons for intercepting the close window button. E.G.: Needing to close file references or release external hardware. Or putting dangerous industrial equipment into a safe state before the program is allowed to release control.
Also may i ask what does your program do cos i can't think of any other reason why you wouldn't want the program to be closed.

Some AV's do this, like my personal favourite NOD32.
Topic archived. No new replies allowed.