What would be the correct way to shutdown a users computer from my application? Can you provide a way that will work for all versions of windows?
Thanks
Printable View
What would be the correct way to shutdown a users computer from my application? Can you provide a way that will work for all versions of windows?
Thanks
There is an API function called SH_SHUTDOWN (google "api-guide" for details).
Also see the DOS "shutdown" command (whih you can call using Process.Start("Shutdown...") )
If your app is only going to be used on NT-based OSes then starting a shutdown process is quite flexible. If you need support for older Windows versions then go the API route. SHShutDownDialog will display the Windows shutdown dialog. ExitWindowsEx will shutdown the system. There is also the option of the Shutdown class from Mentalis (see my signature) that encapsulates all that stuff and presents you with a simple-to-use interface.
Thanks for that....but I am a newbie to API Calls....Can anyone provide me with a sample code that I can use in VB.net 2002 to call the ExitWindowsEx Api?
Thanks
There are many examples posted on the forum already. A quick search should turn up what you need. Like I said, you can avoid using API calls youself if you use the class provided by Mentalis. They wrap the APIs in a .NET class so they are hidden from you, although you have the source so you can see how they do it.
this works for me
'this will shut down the system.
Process.Start("shutdown", "-s -t 00")
Shutdown.exe exists only in NT-based OSes. Windows Me and earlier do not support it, so if you need to support those operating systems then you need to use APIs.Quote:
Originally Posted by FireKnox101
O i didnt know that =), that is good to know ty