title: Are Windows-GUI calls (creating visible windows, etc.) allowed in a Windows-Service?
body: <p>First off, I know <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502%28v=vs.85%29.aspx" rel="nofollow">some proper ways</a> of making a truly interactive Windows Service.</p>
  
  <p>The situation is, I do have a tool that <em>does not</em> interact with the user as such. However, it <em>does display</em> <strong>non-blocking</strong> notifications both via popup windows and via the Windows Notification Area (aka System Tray). It also writes a logfile of the notifications it displays.</p>
  
  <p>This tool is normally spawned by a main user application and as long as the main application is a normal application, these notifications do work as intended.</p>
  
  <p>When this tool is spawned by a Windows Service, no notifications are displayed, naturally. (The Desktop Session for the service isn't visible.) But this would be OK, we have the logfile and these notifications are just - notifications, nothing the user absolutely must see under all circumstances.</p>
  
  <p>The question now becomes: <strong>Is a process running in the context of a Service</strong> (the Service itself or any process it starts) <strong>"allowed" to make Windows API calls that display a visible GUI?</strong></p>
  
  <ul>
  <li>Will most Windows API calls (e.g. creating and showing a window, using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb762159%28v=vs.85%29.aspx" rel="nofollow">Shell_NotifyIcon</a>, etc.) behave the same in the invisible session of the service?</li>
  <li>Or would I have to make sure throughout the source code, that no GUI displaying/modifying stuff is called in the context of the service?</li>
  </ul>
  
  <p>And yes, calling <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx" rel="nofollow">::MessageBox</a> is a bad idea because it will block. But I can handle these calls.</p>
  
  <p>And yes, this could be designed better, but it's what I have at the moment and it would be nice if I hadn't to rip the whole tool apart to make sure no GUI related code is run in the service.</p>