Getting Default Browser and Running It
I've got this problem in that getting the default browser, then opening it by way of SheffExecute() passing the name of an HTML file as a parameter doesn't always work.
I look in the HKEY_CLASSES_ROOT\http\shell\open\command key to get the default browser. I then strip out all unwanted crud such as quotes, -nohome parameters and the like thus leaving me with just the absolute path to the browser. Sample strings of what I end up with are as follows:
C:\Program Files\Internet Explorer\iexplore.exe
I get a variety of responses, it seems, depending on the system which is running the program, although I cannot get it to fail on my own system:
1. The browser is not opened at all. This has happened with the first 2 browsers mentioned, but Firefox works OK on my system (not working)
2. The HTML page replaces the most recent instance of the browser (not the desired effect)
3. A new browser instance is created, containing the HTML page passed as the parameter.
It seems as though the version of Windows alters the behaviour as well as the browser. What I'm wondering is this:
1. Does the fact that sometimes you get the MS-DOS pathnames (i.e. restricted to 8 characters, thus PROGRA~1 etc) make a difference when passed to ShellExecute()? If so, is there a way to translate these to their full counterparts?
2. Is there any reason why code such as the following:
(where DefBrowser contains a string pointing to the default browser such as at the start of this post and OutFileName is the complete path to an HTML file)
ShellExecute(hwnd, "open", DefBrowser, OutFileName, NULL, SW_SHOW);
should open a new browser window on some systems, 'take over' a previous session on others, and not do anything at all on others?
Any ideas? Thanks in advance!