views:

208

answers:

2

I want to stop the shutdown / log off API which appears when you have programs open to confirm a shutdown/logoff.

I have an application already that send a reason to the API.

I know this is bad practice but I really need to override / cancel the shutdown with out displaying the API after 5 seconds.

is there any way to hack this or run a custom shutdown script to override the shutdown.

thanks in advance

A: 

You may want to look at this: http://msdn.microsoft.com/en-us/library/aa376871(VS.85).aspx

When I did this functionality I had to do everything in unmanaged C++ as I had problems trying to set the priviledge by using Interop.

You need this flag: EWX_FORCE in ExitWindowsEx.

James Black
thanks for the answer. I can shutdown the comuter fine . its if the power button is pressed or the user uses Start , shutdown i want to cancel the shutdown if either of these situation occur and do my own thing.
Cancel your own thing, or just catch the event and then do your own thing, knowing that the shutdown will happen.Unfortunately, in my experience, if they press the power button there is nothing you can really do, as they can hold it for five seconds and all you can do later is clean up.
James Black
A: 

it doesnt matter about holding it for5 seconds just catching it if it is pressed once. I can do that but vista shows a API screen after 5 seconds which All i want is vista not to show that.

vista shows that because I prevent it from shutting down.