(转) C# sendmessage向记事本发"F5",让记事本显示时间

原文:http://zhidao.baidu.com/question/62255753.html?fr=qrl&fr2=query

 

System.Diagnostics.Process p = new System.Diagnostics.Process();

string strPath = System.Environment.SystemDirectory + @""NotePad.exe";
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(strPath);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
//startInfo.Arguments = "abc.txt";
p.StartInfo = startInfo;
p.Start();

p.WaitForInputIdle(1000);
if (p.Responding)
{
DateTime dt = DateTime.Now;
SendKeys.SendWait("{F5}");
}
else
{
p.Kill();
}

posted on 2009-04-01 11:44  冷月孤峰  阅读(446)  评论(0)    收藏  举报