Solved

Pausing ShellExecuteEx

Posted on 2003-11-17
4
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting IP address 8 126
How to split this in C++ 4 130
What is sub-make ? 2 107
Winapi.Windows.hpp problem 7 46
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

752 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