Hi I am in the process of designing an application. I would like to be able to include a button that will close my application and restart the pc.
Or a button that will shut down my pc.
Is this possible Would I need to make a call to the Windows API
Thanks

Is it possible to call my pcs shutdown or restart method in my application?
AMV5520
Is there a list of the exit codes Do you know what the exit code is to perform a restart
Gueneal
Alan D. Colón submitted this code to PlanetSourceCode which displays the Windows-Shutdown dialog.
Dim ExplorerProcess() As Process
ExplorerProcess = Process.GetProcessesByName("explorer")
ExplorerProcess(0).CloseMainWindow()
NathanE
I placed this code in a button click event handler.
Shell("Shutdown -S")
That worked fine.
krustitoe
Is there an object that I can work with
I am new to win form programming.
Thanks
eddy400
xWindx
Create an instance of the Environment class:
Dim Env As Environment
This object has many useful pieces of information about the computer your app is running on. For example, this is where you can access the system paths of all the special folders (My Documents, System Folder, Program Files, etc.) when you manipulate files in code.
To force a system shutdown you can call:
Env.Exit(ExitCode as Integer)
This will terminate your application and then tell the operating system to perform the shutdown type specified by ExitCode.
Now your program can handle things like the current user not having privileges to shutdown the computer. The Exit method will throw a security exception if the action cannot be performed.
.NET has the ability to do almost anything directly. It is rare that you MUST make an API call to do something. Now, you might have to find and/or download the right reference, if the object you want is not built into .NET by default, but there are lots of SDKs and wrappers that people have written floating around out there.