Page 1 of 1

Detect Windows shutdown etc.

Posted: Sun Jul 18, 2004 6:13 pm
by Decko
How can i see wheter Windows is shutting down, rebooting etc.???

Posted: Mon Jul 19, 2004 7:27 am
by madshi

Posted: Mon Jul 19, 2004 8:02 am
by Decko
hmm...dunno quite what to do. How can i see the difference between shutdonwn and log off? I just need to save wheter the pc shutdown or reboots.

Posted: Mon Jul 19, 2004 8:34 am
by madshi
Well, have you read the experts-exchange thread? Windows doesn't tell you whether you have a shutdown or reboot. The only way (that I know) to get this information is to hook the shutdown APIs - which is very ugly.

Posted: Mon Jul 19, 2004 8:44 am
by Decko
why is that ugly?

Posted: Mon Jul 19, 2004 8:51 am
by madshi
Because hooking APIs system wide is quite a "big thing". It results in a hook dll being injected into all running processes. Sounds a bit like overkill for just wanting to know whether Windows gets shut down or restarted. Whatever, it's the only solution I know.

Posted: Mon Jul 19, 2004 8:56 am
by Decko
oooh......so it takes a lot of cpu-use?

Posted: Mon Jul 19, 2004 9:24 am
by madshi
No. There's a slight danger of instability, if the hook dll does bad things. But if you code it cleanly things should be just fine. Performance should be no problem (= no measureable performance loss).

Posted: Mon Jul 19, 2004 9:38 am
by Decko
k....how do i do??? ill just give it a try...if it goes bad ill just find another solution