vc++: navigating to a url with parameters, Shellexecute doesnt work

I have a link in my dialog which looks something like : "http://www.xyz.com?arg1=val1&arg2=val2" etc.
When I use Shellexecute it works well when the url is only "http://www.xyz.com". But when I make the get request with the parameters as in line 1, the website throws a page moved or expired page. Meanwhile when I paste the same url in the browser and go, it works fine, taking me to the next page.
I have tried using IWebbrowser2.navigate(url, null,null,null,null) also but same result. Please advise.
swapnil001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AxterCommented:
Please post your code.
0
rstaveleyCommented:
Well I've just tried...

--------8<--------
#include "windows.h"
#pragma comment(lib,"shell32.lib")
int main(int argc,const char* argv[])
{
      if (argc > 1)
            ShellExecute(NULL, "open", *++argv, NULL, NULL, SW_SHOWNORMAL);
}
--------8<--------

And it fires up Mozilla nicely on my system, when I run the program with the parameter "http://search.experts-exchange.com/search.jsp?query=shellexecute&searchType=all&Submit.x=24&Submit.y=9&restrictToTA=on¤tTAID=84"

What do you get with this?
0
mrwad99Commented:
>> IWebbrowser2.navigate

You need to use Navigate2 (http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/methods/navigate2.asp)

I have used this with querystrings no problem.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Jaime OlivaresSoftware ArchitectCommented:
You have to enclose your url between double quotes before calling shellexecute

0
swapnil001Author Commented:
my code :
      HRESULT hr;
      IWebBrowser2* pWebBrowser = NULL;
      HRESULT comInit = CoInitializeEx(NULL,COINIT_MULTITHREADED);
      hr = CoCreateInstance (CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (LPVOID*)&pWebBrowser);
      if (SUCCEEDED (hr) && (pWebBrowser != NULL))
      {
            m_pWebBrowser = pWebBrowser;
            m_pWebBrowser->put_Visible (VARIANT_TRUE);
      }
      else
      {
            if (pWebBrowser)
                  pWebBrowser->Release ();
      }
      BSTR x = url.AllocSysString();
      COleVariant noArg;
      m_pWebBrowser->Navigate(x,&noArg,&noArg,&noArg,&noArg);
      SysFreeString (x);

 rstaveley, what does *++argv stand for ??? is that the url somehow?
mrwad if i use navigate2, do i need to specify any of the other arguments in the function??
0
mrwad99Commented:
>> mrwad if i use navigate2, do i need to specify any of the other arguments in the function??

No.
0
rstaveleyCommented:
>  rstaveley, what does *++argv stand for ??? is that the url somehow?

argv points to an array of character pointers, which has the command line arguments. The ++ increments the pointer and * dereferences it. It would have been more legible if I'd written argv[1] - *++argv is a quirky old habit :-)

--------8<--------
#include "windows.h"
#pragma comment(lib,"shell32.lib")
int main(int argc,const char* argv[])
{
     if (argc > 1)
          ShellExecute(NULL, "open", argv[1], NULL, NULL, SW_SHOWNORMAL);
}
--------8<--------

This is a command line program. Run it with the command line parameter "http://search.experts-exchange.com/search.jsp?query=shellexecute&searchType=all&Submit.x=24&Submit.y=9&restrictToTA=on¤tTAID=84"
0
swapnil001Author Commented:
thanks mrwad navigate2 worked out just fine for me.
0
mrwad99Commented:
Glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.