views:

123

answers:

2

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++?

A: 

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.

Marcus Erickson
It's of course _impossible_ to not specify the protocol for the URL. The protocol is the part before the first `:`. If there's no such part, then the input isn't a URL in the first place.
MSalters
A: 

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).

Agoln