G
Guest
I want use C# to restart my computer,
how to?
how to?
[DllImport("advapi32.dll", EntryPoint="InitiateSystemShutdown")]
public static extern int InitiateSystemShutdownA(string lpMachineName,
string lpMessage, int dwTimeout, int bForceAppsClosed, int
bRebootAfterShutdown);
public void RestartPC(object sender, System.EventArgs e)
{
int restartcode=InitiateSystemShutdownA("\\127.0.0.1", "Restart...", 10,
1, 1);
MessageBox.Show("OK"+restartcode);
}
Am i right?
but the parameter restartcode is 0,and my computer still run.
W.G. Ryan eMVP said:You cna use the API
http://custom.programming-in.net/articles/art9-1.asp?f=InitiateSystemShutdown
Or you can freestyle and just loop through each active process on your
computer and shut it down -
--
W.G. Ryan MVP (Windows Embedded)
TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com