Why is my application not showing when starting my service

[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 used this code in my onsessionchange event service, the service starts my app on registration, but the app is hidden but running. i could not view

0


a source to share


1 answer


By default, services do not have access to any session, not the logon session, not the secure UAC in Vista, not even shared user sessions. Therefore, they have nowhere to show their windows. It's good. There are hacks around it, but the correct way is probably to create a process in Windows Station "Winsta0". Set STARTUPINFO.lpDesktop ="winsta0\default";

on callCreateProcess( )



+1


a source







All Articles