Detect Windows shutdown etc.

c++ / delphi package - dll injection and api hooking
Post Reply
Decko
Posts: 7
Joined: Sun Jul 18, 2004 6:06 pm
Location: Denmark

Detect Windows shutdown etc.

Post by Decko »

How can i see wheter Windows is shutting down, rebooting etc.???
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Decko
Posts: 7
Joined: Sun Jul 18, 2004 6:06 pm
Location: Denmark

Post 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.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post 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.
Decko
Posts: 7
Joined: Sun Jul 18, 2004 6:06 pm
Location: Denmark

Post by Decko »

why is that ugly?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post 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.
Decko
Posts: 7
Joined: Sun Jul 18, 2004 6:06 pm
Location: Denmark

Post by Decko »

oooh......so it takes a lot of cpu-use?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post 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).
Decko
Posts: 7
Joined: Sun Jul 18, 2004 6:06 pm
Location: Denmark

Post by Decko »

k....how do i do??? ill just give it a try...if it goes bad ill just find another solution
Post Reply