我想通过service.i运行在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);
}
}
日志文件不会显示任何异常。
目的是在窗口的欢迎屏幕上启动应用程序,以便用户可以使用自定义键盘。
答案 0 :(得分:2)
什么操作系统?从Vista及以后你不能从服务创建GUI(这是一个安全漏洞和丑陋......)有一个用户0会话显示由vista开始的服务启动gui。
为什么不在安装应用的用户登录时为您的应用创建注册表项和/或启动条目?或者按照info here关于实施互动服务。
答案 1 :(得分:0)
服务通常在登录用户以外的用户下运行,因此该服务没有可用于显示任何窗体的桌面,因此没有显示t的原因。
我认为你需要找到另一种方式,因为尽管winforms应用程序可以启动服务我不相信它可以通过其他方式完成。
此致
AJ