• λ我爱Aspx >> Asp.Net >> 使用C#编写的一个定时关机程序
  • 使用C#编写的一个定时关机程序

  • :未知  Դ:internet  :2007-5-20 16:43:52  ؼ:c#
  • protected static void SuspendSystem(bool hibernate , bool force ){

    if (!CheckEntryPoint("powrprof.dll", "SetSuspendState"))

    throw new PlatformNotSupportedException("The SetSuspendState method is not supported on this system!");

    SetSuspendState((int)(hibernate ? 1 : 0), (int)(force ? 1 : 0), 0);

    }

    /// <summary>

    /// Checks whether a specified method exists on the local computer.

    /// </summary>

    /// <param name="library">The library that holds the method.</param>

    /// <param name="method">The entry point of the requested method.</param>

    /// <returns>True if the specified method is present, false otherwise.</returns>

    protected static bool CheckEntryPoint(string library , string method ) {

    IntPtr libPtr = LoadLibrary(library);

    if (!libPtr.Equals(IntPtr.Zero)) {

    Ҷƪл˵?
  • һƪ使用C#控制远程计算机的服务
    һƪ得到系统进程和结束某个指定的进程