title: ShellExecuteEx on windows 7 with default image / photo viewer
body: <p>We have a desktop application running on Windows XP, Windows Vista, Windows 7 and so on (it is written in cobol, but I think in this case it is not relevant).  </p>
  
  <p>In our source code we call <code>ShellExecuteEx</code> with <code>open</code>.<br>
  After this - in order to wait for the termination of the called programm - we call <code>WaitForSingleObject</code> with <code>infinite</code>.  </p>
  
  <p>It is working without problems, only on windows-7-machines with images and the default image viewer we have problems.</p>
  
  <p>If <code>ShellExecuteEx</code> is called there for a jpg or tif file and the machine has only the default windows image / photo viewer, an error occurs. <code>WaitForSingeObject</code> returns <code>WAIT_FAILED</code> and <code>GetLastError()</code> says: <code>INVALID_HANDLE</code>.</p>
  
  <p>This DOES NOT HAPPEN on windows 7, when there is another image viewer, for example, Picasa Photo Viewer, or Evince windows version or JPEGView.</p>
  
  <p>I do not know where the problem is with the default image viewer on windows 7 and <code>ShellExecuteEx</code>. <code>ShellExecuteEx</code> DOES NOT return an error code!</p>
  
  <p>Thanks alot in advance.</p>
  
  <p>Update:
  Thank you for your answers.</p>
  
  <p>@David Heffernan:
  As you said, in the case where it does NOT work, ShellExecuteEx has an return code (hInstApp) of 42 (ok!) and hProcess is NULL! (The only new process started was dllhost.exe.)</p>
  
  <p>But, I tested the whole thing on another windows 7 machine. In this case i did the following:<br>
  - On this machine Picasa was the default viewer.<br>
  - I switched back to the default (Windows Photo Viewer).<br>
  - It worked!<br>
  - Then I did NOT close photo viewer and pressed "show" in our application AGAIN.
  - It also worked (a new instance of the viewer popped up), even when the Windows Photo Viewer was already running!</p>