我怎么从windows service看到windows窗体。我可以吗? [英] How do i see windows form from windows service.how can i?

查看:72
本文介绍了我怎么从windows service看到windows窗体。我可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在进程启动时运行我的win表单的.exe文件但是无法看到window.my进程在我检查任务管理器时启动并运行。问题仅在于显示表单。



我尝试了什么:



{

string FilePath = Path。合并(AppDomain.CurrentDomain.BaseDirectory,WinForm.exe);

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

myProcess.StartInfo .FileName = FilePath;

myProcess.StartInfo.CreateNoWindow = false;

myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

try

{

myProcess.Start();

}

catch(exception ex)

{

wr.WriteLine(Process Starts ??+ ex.ToString());

}

myProcess.WaitForExit();

}

i tried to run .exe file of my win form when process starts but unable to see window.my process starts and running when i checked task manager.the problem is only in showing form.

What I have tried:

{
string FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"WinForm.exe");
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = FilePath;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
try
{
myProcess.Start();
}
catch (Exception ex)
{
wr.WriteLine("Process Starts??" + ex.ToString());
}
myProcess.WaitForExit();
}

推荐答案

Windows服务没有 UI,这是设计的。



如果你需要与正在运行的窗口进行通信为您提供实现机制和协议的服务,并让基于用户的流程获取并设置该协议的数据。
Windows Services have no UI, that is by design.

If you need to communicate with a running windows service you to implement a mechanism and protocol and have a user based process get and set data on that protocol.


您的服务正在一个无权访问的process \ session中运行桌面,因此它可以启动您的过程,但无法看到GUI。当没有人登录时服务也会运行,所以当没有人登录到盒子时会发生什么,你期望发生什么呢?



c# - 有没有办法从Windows 7上的Windows服务启动GUI应用程序? - 堆栈溢出 [ ^ ]
Your service is running under a process\session that doesn't have access to the desktop so it can launch your process but the GUI can't be seen. Services also run when no-one is logged in, so what happens when no-one is logged into the box, what do you expect to happen then?

c# - Is there any way to start a GUI application from a windows service on Windows 7? - Stack Overflow[^]


这篇关于我怎么从windows service看到windows窗体。我可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆