Solved

Pausing ShellExecuteEx

Posted on 2003-11-17
4
268 Views
Last Modified: 2010-04-02
Why does this routine fail to wait?

The ShellExecuteEx manages to open a web page, but the WaitForSingleObjectEx shows the error message Invalid handle.

Testing on windows 98.

Any clues?

Sorry about low points, been sick latley. I will add more points later and/or give the answerer a freebee question. I always grant an A.

RJSoft


      // TODO: Add extra validation here
      DWORD Error;
      char Start[1000];
      m_EditBox.GetWindowText(Start,999);

      SHELLEXECUTEINFO si;
      memset(&si, 0, sizeof(si));
      si.cbSize = sizeof(si);
      si.hwnd = this->m_hWnd;
      si.lpVerb = "open";
      si.lpFile=Start;
      si.nShow = SW_NORMAL;
      si.fMask = SEE_MASK_NOCLOSEPROCESS;

      bool res = ShellExecuteEx(&si);
      
      if(res<=0)MessageBox("Shell failed");
      
      else
      {
      DWORD Flag=WaitForSingleObjectEx(si.hProcess,INFINITE,0);
      
            if(Flag==WAIT_FAILED)
            {
            LPVOID lpMsgBuf;
            FormatMessage(
                  FORMAT_MESSAGE_ALLOCATE_BUFFER |
                  FORMAT_MESSAGE_FROM_SYSTEM |
                  FORMAT_MESSAGE_IGNORE_INSERTS,
                  NULL,
                  GetLastError(),
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
                  (LPTSTR) &lpMsgBuf,
                  0,
                  NULL
                  );
            // Process any inserts in lpMsgBuf.
            // ...
            // Display the string.
            ::MessageBox( NULL, (LPCTSTR)lpMsgBuf, "WAIT_FAILED", MB_OK | MB_ICONINFORMATION );
            // Free the buffer.
            LocalFree( lpMsgBuf );
       
      }//endelse


      MessageBox("Shell good");
      }
      
0
Comment
Question by:RJSoft
  • 2
  • 2
4 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 25 total points
ID: 9769449
Try this:
Set the lpFile parameter to "IExplorer.com" and set the lpParameters parm to the full URL.
-- Dan
0
 
LVL 3

Author Comment

by:RJSoft
ID: 9792475
Dan the man.
Thanks again.

RJ
0
 
LVL 3

Author Comment

by:RJSoft
ID: 9792520
Just for documentation I used iexplore.exe not com.
RJ
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9792650
Thanks for the points.    Yes, the EXE would tend to be a better choice :)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question