[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
我在我的服务onsessionchange事件中使用了这段代码,该服务在登录事件中启动我的应用程序但是应用程序被隐藏但正在运行。我无法查看
1 个解决方案
#1
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 calling CreateProcess( )
默认情况下,服务无权访问任何会话 - 不是登录会话,而是Vista中的安全UAC,甚至不是普通用户会话。因此,他们无处可以展示他们的窗户。这很好。它周围有黑客,但正确的方法可能是在Windows Station“Winsta0”中创建进程。设置STARTUPINFO.lpDesktop =“winsta0 \ default”;调用CreateProcess()时
#1
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 calling CreateProcess( )
默认情况下,服务无权访问任何会话 - 不是登录会话,而是Vista中的安全UAC,甚至不是普通用户会话。因此,他们无处可以展示他们的窗户。这很好。它周围有黑客,但正确的方法可能是在Windows Station“Winsta0”中创建进程。设置STARTUPINFO.lpDesktop =“winsta0 \ default”;调用CreateProcess()时