title: How can I tell if the current process is a service or not (C++, Win32)?
body: <p>How can I tell if the application my code is running in, is it in a service or an application? Why do I want to know this - I'm writing some code that is injected into the target application and that code has no way of knowing this information up front, so it has to work it out itself.</p>
  
  <p>I cannot rely on any code being called from the service control manager, start, stop, or command line parameters. </p>
  
  <p>I'm currently looking at <code>GetConsoleWindow()</code> which I hope will return <code>NULL</code> for a service (no console) and a window handle for any application (has a console). Not sure how valid this assumption is.</p>
  
  <p>Any ideas for a better solution?</p>