[问]求一个时间秒数的算法 本人想做个一个定时关机,用DateTime获取了日期...系统时间格式: 年/月/日 时/分/秒设定时间格式: 年/月/日 时/分/秒下面想做设定时间减去系统时间的秒数,给个理论也可以..谢谢. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用下面这种方法:C#调用API实现的关机 很简单,几行代码就交工了.Visual C#设计多功能关机程序 Process proc = new Process(); proc.StartInfo.FileName = "cmd.exe"; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardError = true; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.RedirectStandardOutput = true; proc.Start(); string commandLine = String.Empty; switch (option) { case Program.OptionType.isCancel: commandLine += @"shutdown /a"; break; case Program.OptionType.isLogoff: commandLine += @"shutdown /f /l /t" + BLANK + interval; break; case Program.OptionType.isRestart: commandLine += @"shutdown /f /r /t" + BLANK + interval; break; case Program.OptionType.isShutdown: commandLine += @"shutdown /f /s /t" + BLANK + interval; break; } proc.StandardInput.WriteLine(commandLine); 或 [DllImport("user32.dll")] static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason); http://topic.csdn.net/u/20090730/23/835694dd-ea4a-4651-8d78-5bf7cec57df4.html 计算两个时间相差的秒数,JJWW DateTime dt = DateTime.Parse("2010-03-01 12:00:00");TimeSpan ts = dt - DateTime.Now;MessageBox.Show(ts.TotalSeconds.ToString()); for(;;){if (DateTime.Now >= ShutDownTime){ ShowDownComputer(); }} 正则表达式 匹配点js 但不匹配点jsp TreeView控件绑定了ImageList后总会默认的添加SelecImageIndex和ImageIndex 求助 正则表达式 在线等 如何用c#2005做不规则报表 关于SQL SERVER高并发访问的解决办法 如何绑定COMBOBOX啊? 如何限制非授权者调用组件中提供的方法? 强制类型转换问题 请问 一个关于crystal 的问题 大虾们写写了 请问高手Session一样功能,但只在一个页面存在的是什么?急用!!!! 如何实现 winfrom 中 dateview与 treeview 展示样式结合 CSV文件格式问题
C#调用API实现的关机
Visual C#设计多功能关机程序
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string commandLine = String.Empty;
switch (option)
{
case Program.OptionType.isCancel:
commandLine += @"shutdown /a";
break;
case Program.OptionType.isLogoff:
commandLine += @"shutdown /f /l /t" + BLANK + interval;
break;
case Program.OptionType.isRestart:
commandLine += @"shutdown /f /r /t" + BLANK + interval;
break;
case Program.OptionType.isShutdown:
commandLine += @"shutdown /f /s /t" + BLANK + interval;
break;
}
proc.StandardInput.WriteLine(commandLine);
或 [DllImport("user32.dll")]
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
http://topic.csdn.net/u/20090730/23/835694dd-ea4a-4651-8d78-5bf7cec57df4.html
TimeSpan ts = dt - DateTime.Now;
MessageBox.Show(ts.TotalSeconds.ToString());
if (DateTime.Now >= ShutDownTime)
{
ShowDownComputer();
}
}