Run url in new window using C ++ (Windows)

How to launch a URL in a new window using C ++ (Windows only)?

The direct approach seems to open a new tab in an existing browser window. (Or, if tabbed browsing is disabled, the new URL captures the existing browser window).

This is for a (large) desktop using MFC and Qt.

+4
source share
4 answers

I used this to display the locally generated html in the default browser, in my case the file name is something like "c: \ temp \ page.html", maybe replacing the file name with a URL might work?

ShellExecute(NULL,"open",filename,NULL,NULL,SW_SHOWNORMAL); 

Updated: http://support.microsoft.com/kb/224816

How ShellExecute determines whether to start a new instance When ShellExecute scans the registry, it looks for the \ open shell section. If the shell key \ open \ ddeexec is defined, then the Dynamic Data Exchange (DDE) message with the specified IExplore application and WWW_OpenURL theme is sent to all top-level windows on the desktop. The first application to reply to this message is an application that is sent to the requested URL. If the application does not respond to this DDE message, then ShellExecute uses the information contained in the \ open \ shell section to start the application. It then retransmits the DDE message to go to the requested URL.

So it looks like you have no control over opening a new window. No matter which browser is currently running, it can open it in any way.

+8
source

It is controlled by windows. The only way to explicitly open it in a new browser window is to open the browser explicitly and give it a URL.

0
source

Here is a link to the code that will open the URL in a new browser . The code scans the default application to process the HTML document and then explicitly opens that application with a call to ShellExecute.

0
source

You cannot at all. A custom browser can do whatever the user wants.

One way to achieve the desired effect can be to embed a specific browser in your own window (for example, an ActiveX IE control) and render your URL.

0
source

All Articles