tags:

views:

98

answers:

1
[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

+1  A: 

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( )

MSalters
could you pls provide me the sample code, i can start a test application and view it but i couldn't view my login application which is run in a separate desktop
JKS