title: How do I use PostThreadMessage to close internet explorer from C++
body: <p>I'm trying to start <code>iexplore.exe</code> let it run for 5 seconds and then close it again.</p>
  
  <p><code>iexplore</code> opens just fine however it doesn't close when I call the PostThreadMessage. 
  Can anyone see what I'm doing wrong? Here is my code:</p>
  
  <pre><code>CString IEPath = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";//GetIEPath();
  //IEPath += ' ' + url;
  std::string strCommand((LPCTSTR)IEPath);
  PROCESS_INFORMATION    procinfo;
  STARTUPINFO    startupinfo;    
  GetStartupInfo(&amp;startupinfo);
  
  CreateProcess(
          NULL,       
          (char *)strCommand.c_str(),// name of executable module
          NULL,           // lpProcessAttributes
          NULL,           // lpThreadAttributes
          false,          // handle inheritance option
          CREATE_SHARED_WOW_VDM,              // creation flags
          NULL,           // new environment block
          NULL,           // current directory name
          &amp;startupinfo,    // startup information
          &amp;procinfo        // process information
          );
  
  
  Sleep(5000);
      ::PostThreadMessage(procinfo.dwThreadId, WM_QUIT, 0, 0); //&lt;---Dosent Close internet explorer!
  </code></pre>
  
  <p>Anyone have an idea of what I'm doing wrong? Or is there better way what to do the trick?</p>