title: ShellExecuteEx with SEE_MASK_FLAG_NO_UI displays error when starting .NET app on system without .NET
body: <p>The <code>ShellExecuteEx</code> Win32 function call has a flag <code>SEE_MASK_FLAG_NO_UI</code> in its <code>SHELLEXECUTEINFO</code> structure, which should suppress any error dialogs which could be displayed because of an error when launching an application.</p>
  
  <p>The MSDN documentation <a href="http://msdn.microsoft.com/en-us/library/bb759784(VS.85).aspx" rel="nofollow noreferrer">here</a> is quite explicit about it:</p>
  
  <pre><code>SEE_MASK_FLAG_NO_UI
    0x00000400. Do not display an error message box if an error occurs.
  </code></pre>
  
  <p>In my case, I am launching a .NET executable on a Windows XP system where no .NET is installed. I systematically receive the following message, displayed by Windows in a dialog window:</p>
  
  <pre><code>Xxx.exe - Application Error
  The application failed to initialize properly (0xc0000135).
  Click on OK to terminate the application.
  [ OK ]
  </code></pre>
  
  <p>I don't want the user to have to deal with this message. I'd rather get back an error code from <code>ShellExecuteEx</code> and be able to handle it gracefully in my program. Here is the code snippet which I am using to start the external executable:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  
  int wmain(int argc, wchar_t* argv[])
  {
      SHELLEXECUTEINFO info;
      memset(&amp;info, 0, sizeof(SHELLEXECUTEINFO));
      info.cbSize = sizeof(SHELLEXECUTEINFO);
      info.fMask = SEE_MASK_FLAG_NO_UI;
      info.lpVerb = L"open";
      info.lpFile = L"Xxx.exe";
      info.nShow  = SW_SHOW;
      return ShellExecuteEx (&amp;info);
  }
  </code></pre>
  
  <p>Is there an official way of suppressing the error message if .NET is not present on the system? Or do I have to check for this specific condition myself before executing the application (but I do not know in advance if it is a .NET app or a native app). And what if the app I am starting is missing some DLLs, for instance?</p>