为什么我的应用程序在由我的服务启动时不显示
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_SHOW =5;
string Tartgetfile = @"C:\BringLog.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.FileName = Tartgetfile;
try
{
if (p.Start() == true)
{
ShowWindow(p.Handle, SW_SHOW);
WriteToLog("PROCESS STARTED");
}
else
{
WriteToLog("FAILED TO START PROCESS");
}
}
catch (Exception ex)
{
WriteToLog("FAILED TO START PROCESS" + ex.Message+ ex.Source);
}
我在我的服务 onsessionchange 事件中使用了此代码,该服务在登录事件上启动我的应用程序,但应用程序已隐藏但正在运行。 我无法查看
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_SHOW =5;
string Tartgetfile = @"C:\BringLog.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.FileName = Tartgetfile;
try
{
if (p.Start() == true)
{
ShowWindow(p.Handle, SW_SHOW);
WriteToLog("PROCESS STARTED");
}
else
{
WriteToLog("FAILED TO START PROCESS");
}
}
catch (Exception ex)
{
WriteToLog("FAILED TO START PROCESS" + ex.Message+ ex.Source);
}
i have used this code in my service onsessionchange event, the service start my application on logon event but application is hidden but running. i couldn't view
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,服务无权访问任何会话 - 登录会话、Vista 中的安全 UAC、甚至普通用户会话都无权访问。 因此,他们没有地方展示他们的窗户。 这很好。 有一些破解方法,但正确的方法可能是在 Windows Station“Winsta0”中创建进程。 调用
CreateProcess( )
时设置STARTUPINFO.lpDesktop ="winsta0\default";
By default, services do not have access to any session - not the logon session, not the secure UAC in Vista, not even the common user sessions. Hence, there's nowhere for them to show their windows. This is good. There are hacks around it, but the proper way is probably to create the process in Windows Station "Winsta0". Set
STARTUPINFO.lpDesktop ="winsta0\default";
when callingCreateProcess( )