I made a Windows - Auto shutdown program.
Program sources are very easy to understand.
AutoShutdown.zip are including all my C# source file and codes, even icon downloaded in free icon sites
Development environment: Visual studio 2012 express
I just used some objects, It's very simple programming.
Timer algorithm:
private void Changes(object sender, EventArgs e)
{
int H = int.Parse(textBox2.Text);
int M = int.Parse(textBox1.Text);
int S = int.Parse(textBox3.Text);
if (S != 0)
{
S--;
}
else if (M != 0)
{
M--;
S = 59;
}
else if (H != 0)
{
H--;
M = 59;
S = 59;
}
SetChange(H, M, S);
if (H == 0 && M == 0 && S == 0)
{
EndofComputer();
}
}
private void SetChange(int H, int M, int S)
{
textBox2.Text = H.ToString();
textBox1.Text = M.ToString();
textBox3.Text = S.ToString();
}
That's all.
The way to shutdown the winodws:
private void EndofComputer()
{
Process.Start("shutdown", "/s /t 0");
}
It's very easy.
"/s /t 0" is an argument of process("shutdown");
It's the same thing to writhe "shutdown /s /t 0" in command line.
You can use my source codes for free.
But if you want to share this source, then please write my blogs adress. (quotation, citation)
thank you.
'Windows_ > Windows_C# & App' 카테고리의 다른 글
C# ComboBox 수정 못하게 하는법 (0) | 2015.01.15 |
---|---|
C# 마우스 클릭, 위치정보 가져오기 (3) | 2014.12.03 |
C# Socket Multi-thread echo server/client 예제 (4) | 2014.10.08 |
C# Socket echo server/client 예제 (1) | 2014.10.08 |
C#: 주기, 시간마다 같은행동 반복하기 (2) | 2014.09.04 |