【发布时间】:2011-06-25 08:47:29
【问题描述】:
我想通过service运行一个c#winform制作的应用程序。我已经完成了代码但是应用程序没有启动即使服务成功启动并且没有抛出异常。
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("starting Kb");
try
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"C:\Program Files (x86)\Invisual E. Inc\KeyboardSetup\keyboard.exe";//Exe Path
myProcess.StartInfo.CreateNoWindow = false;
myProcess.EnableRaisingEvents = true;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
myProcess.Start();
ProcessWindowStyle ws = myProcess.StartInfo.WindowStyle;
if (ws == ProcessWindowStyle.Hidden)
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
eventLog1.WriteEntry("started");
}
catch (Exception c)
{
eventLog1.WriteEntry(c.Message);
}
}
日志文件没有显示任何异常。
目的是在窗口的欢迎屏幕上启动应用程序,以便用户可以使用自定义键盘。
【问题讨论】: