BeforeNavigate2 does not return URL parameters

1.1k views Asked by At

I have a C++ program that display a browser using the Microsoft WebBrowser control. I pass hints in the URL parameters to the code so that alternative actions can be taken rather then simply allowing the browser to navigate to the new page.

For example, I might pass the URL "WRITE.EXE?RUN" to indicate that I want to run the executable in the URL.

In C#, I get the entire URL in the BeforeNavigate event but I only get the URL up to the ?. So in C# I get "WRITE.EXE?RUN" whereas in C++ the URL passed to BeforeNavigate2 is just "WRITE.EXE"

Any ideas on how to access the entire URL via C++?

2

There are 2 answers

1
Marcus Erickson On

I beleive the problem here is caused by the fact that since I dont specify a protocol for the URL, the WebBrowser handle it differently.

So if I specify http://write.exe?RUN, I get the whole URL path including the parameters whereas if if leave the protocol off or specify FILE://write.exe?RUN, it removes the arguments. The nice thing about the file protocol is that will return the entire path of the EXE as the URL.

0
Logan B. On

Without passing a URL, I'm only assuming that Windows is not binding it to a URL moniker, and the moniker which it is bound to strips it of the path.

A URL (As defined by RFC 1738) is: <scheme>:<scheme-specific>

Without more details it's unclear what you're doing with the web browser control and how you need to handle what is passed into it, but answering those questions will determine if you need to write your own URL moniker (such as myapp://write.exe?dosomething).