How to reboot local machine in c# using InitiateSystemShutdown(...) ---a function in "advapi32.dll"

  • Thread starter Thread starter mrzt
  • Start date Start date
M

mrzt

the following codes won't work.
==============================
using System;
using System.Runtime;
using System.Runtime.InteropServices;

namespace Shutdown
{
/// <summary>
/// Class1 µÄժҪ˵Ã÷¡£
/// </summary>
class Class1
{
/// <summary>
/// Ó¦ÓóÌÐòµÄÖ÷Èë¿Úµã¡£
/// </summary>
[DllImport("advapi32.dll")]
public static extern bool InitiateSystemShutdown(string Machinename,string
Message,long Timeout,int ForceAppsClosed,int RebootAfterShutdown);

[STAThread]
static void Main(string[] args)
{
//
// TODO: ÔÚ´Ë´¦Ìí¼Ó´úÂëÒÔÆô¶¯Ó¦ÓóÌÐò
//
InitiateSystemShutdown("","",30,1,1);
}
}
}
 
Back
Top