的聲音,忽醒,一" />

黄色网页视频 I 影音先锋日日狠狠久久 I 秋霞午夜毛片 I 秋霞一二三区 I 国产成人片无码视频 I 国产 精品 自在自线 I av免费观看网站 I 日本精品久久久久中文字幕5 I 91看视频 I 看全色黄大色黄女片18 I 精品不卡一区 I 亚洲最新精品 I 欧美 激情 在线 I 人妻少妇精品久久 I 国产99视频精品免费专区 I 欧美影院 I 欧美精品在欧美一区二区少妇 I av大片网站 I 国产精品黄色片 I 888久久 I 狠狠干最新 I 看看黄色一级片 I 黄色精品久久 I 三级av在线 I 69色综合 I 国产日韩欧美91 I 亚洲精品偷拍 I 激情小说亚洲图片 I 久久国产视频精品 I 国产综合精品一区二区三区 I 色婷婷国产 I 最新成人av在线 I 国产私拍精品 I 日韩成人影音 I 日日夜夜天天综合

半夜聽到黃家駒的聲音, 忽醒,一身冷汗,哦,原來

系統(tǒng) 1945 0

(一).說明

我平時(shí)喜歡聽?zhēng)资赘柙訇P(guān)機(jī)睡覺,夏天還好,冬天光著身子去關(guān)機(jī)要凍個(gè)半死 :(,因此為這事做了個(gè)最簡(jiǎn)單的自動(dòng)關(guān)機(jī)程序,讀者如果用得著,就下載用一下吧

最近用這個(gè)程序爽多了 . 基于以下原因:

1. 睡覺之前不用顧慮: " 哎呀,計(jì)算機(jī)還開著,等下還得去關(guān)掉"

2.省電. 一天兩天忘了關(guān)機(jī)交電費(fèi)還撐的住,如果長(zhǎng)期下去,一大筆電費(fèi)咋交得起啊.

就算有錢也不心甘交這冤枉錢,給鬼聽啊.

3.夏天跑去關(guān)機(jī)還好,如果是冬天的話,要凍個(gè)半死

4.恐怖啊! 半夜聽到<黃家駒>的聲音, 忽醒,一身冷汗,原因是計(jì)算機(jī)忘了關(guān),它還在播放Beyond演唱會(huì)

跟讀者開了些玩笑.

(二).程序簡(jiǎn)單示例圖

半夜聽到黃家駒的聲音, 忽醒,一身冷汗,哦,原來是計(jì)算機(jī)忘了關(guān),還在播放Beyond演唱會(huì).于是做了個(gè)較簡(jiǎn)單的自動(dòng)關(guān)機(jī)程序(代碼下載)

如果您感興趣的話,還可以繼續(xù)增加好多功能,比如:重啟機(jī)器/待機(jī)/睡眠等狀態(tài),還有倒計(jì)時(shí)功能

(三).代碼

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;

namespace ShutDownComputer
{
/// <summary>
/// Form1 的摘要說明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}

/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.timer1 = new System.Timers.Timer();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.BackColor = System.Drawing.Color.Olive;
this.button1.Location = new System.Drawing.Point(88, 184);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "開始";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 23);
this.label1.TabIndex = 2;
this.label1.Text = "您想讓你的計(jì)算機(jī)在";
//
// comboBox1
//
this.comboBox1.Items.AddRange(new object[] {
"10",
"20",
"30",
"40",
"50",
"60",
"70",
"80",
"90",
"100",
"110",
"120"});
this.comboBox1.Location = new System.Drawing.Point(64, 104);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(88, 20);
this.comboBox1.TabIndex = 3;
this.comboBox1.Text = "30";
//
// label2
//
this.label2.Location = new System.Drawing.Point(152, 112);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(104, 16);
this.label2.TabIndex = 4;
this.label2.Text = "分之后自動(dòng)關(guān)機(jī)";
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 32);
this.label3.Name = "label3";
this.label3.TabIndex = 5;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.SynchronizingObject = this;
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
this.ClientSize = new System.Drawing.Size(280, 238);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 應(yīng)用程序的主入口點(diǎn)。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}


[StructLayout(LayoutKind.Sequential, Pack=1)]

internal struct TokPriv1Luid
{
public int Count;

public long Luid;

public int Attr;

}

[DllImport("kernel32.dll", ExactSpelling=true) ]

internal static extern IntPtr GetCurrentProcess();

[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]

internal static extern bool OpenProcessToken( IntPtr h, int acc, ref IntPtr phtok );

[DllImport("advapi32.dll", SetLastError=true) ]

internal static extern bool LookupPrivilegeValue( string host, string name, ref long pluid );

[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]

internal static extern bool AdjustTokenPrivileges( IntPtr htok, bool disall,

ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen );

[DllImport("user32.dll", ExactSpelling=true, SetLastError=true) ]

internal static extern bool ExitWindowsEx( int flg, int rea );

internal const int SE_PRIVILEGE_ENABLED = 0x00000002;

internal const int TOKEN_QUERY = 0x00000008;

internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;

internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";

internal const int EWX_LOGOFF = 0x00000000;

internal const int EWX_SHUTDOWN = 0x00000001;

internal const int EWX_REBOOT = 0x00000002;

internal const int EWX_FORCE = 0x00000004;

internal const int EWX_POWEROFF = 0x00000008;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Timers.Timer timer1;

internal const int EWX_FORCEIFHUNG = 0x00000010;

private void DoExitWin( int flg )

{

bool ok;

TokPriv1Luid tp;

IntPtr hproc = GetCurrentProcess();

IntPtr htok = IntPtr.Zero;

ok = OpenProcessToken( hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok );

tp.Count = 1;

tp.Luid = 0;

tp.Attr = SE_PRIVILEGE_ENABLED;

ok = LookupPrivilegeValue( null, SE_SHUTDOWN_NAME, ref tp.Luid );

ok = AdjustTokenPrivileges( htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero );

ok = ExitWindowsEx( flg, 0 );

}


DateTime ShutDownItTime = new DateTime();
int status = 0; //0: 表示還沒有開始計(jì)時(shí)關(guān)機(jī); 1: 已經(jīng)開始計(jì)時(shí)關(guān)機(jī)
private void button1_Click(object sender, System.EventArgs e)
{
if(status == 1)
{
this.timer1.Enabled = false;
status = 0;
this.button1.Text = "開始";
return;
}
int intTime = 0;
if(this.comboBox1.Text.Length == 0)
{
this.label3.Text = "請(qǐng)輸入時(shí)間!";
return;
}
try
{
intTime = int.Parse(this.comboBox1.Text);
}
catch
{
this.label3.Text = "時(shí)間只能為整數(shù),請(qǐng)重新輸入!";
}
this.ShutDownItTime=DateTime.Now.AddMinutes(intTime);
this.timer1.Enabled = true;
status = 1;
this.button1.Text = "停止";
}


private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if(DateTime.Now >= this.ShutDownItTime)
{
this.label3.Text = "正在關(guān)機(jī)...";
DoExitWin(EWX_SHUTDOWN);
}

}
}
}

(三).源程序代碼下載

http://www.cnblogs.com/Files/ChengKing/ShutDownComputer.rar

半夜聽到黃家駒的聲音, 忽醒,一身冷汗,哦,原來是計(jì)算機(jī)忘了關(guān),還在播放Beyond演唱會(huì).于是做了個(gè)較簡(jiǎn)單的自動(dòng)關(guān)機(jī)程序(代碼下載)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論