views:

219

answers:

2

I am trying to build an install CD with a custom MFC application set to autorun when the CD is inserted.

The instructions are included as a simple html page with images and links to PDF documents, all of which are located on the CD.

In the past I'd used the following to open the html page with the default browser:

ShellExecute(NULL, "open", <full path to .htm file including CD drive letter>, NULL, NULL, SHOWNORMAL);

But when testing with IE8 under vista I've encountered the following:

  1. Explorer launches
  2. The tab says 'Connecting'
  3. Explorer dissappears

This has to do with protected mode, since if you turn off protected mode for the internet zone, the problem goes away.

The strange thing is that the problem only shows up once everthing is burned onto a CD. If I just run the autorun executable manually from my hard drive, the html page comes up just fine.

So I'm asking if there is anything specific I can do to fix this? Or if there is another mechanism for opening URLs with the user's default browser that might not have this problem?

A: 

Since you can be reasonably sure that IE is installed you might want to execute

iexplore.exe [URL]

in your shellex call.

In case IE is not installed, check the return value to see if it isn't not found. If so do your original shellex call directly on the .htm file.

Alternatively, You can copy the .htm to a %TEMP%, and run the shellex call from there. That way it gets around the protected aceess from a "risky" location.

Byron Whitlock
Rather then force IE, I've got some code to check the registry key for the default browser, and if it appears to be IE I can try a workaround. However by doing ShellExecute with iexplore and the URL, I still get the same behavior. If I bring up a instance of IE first and then do the ShellExecute "open", then you get the page comming up correctly, but also an extra browser window.I haven't tried the copy to %TEMP% yet, so we'll see if that has any effect.
On furthur reflection, a temp copy would only work if I either generated a new html page with FILE:// links to the images and PDFs on the CD, or copied the whole directory structure to the temp folder. Plus there are issues with when to clean up afterwards. So even if this works, it wouldn't solve my problem.
<base href=""> is your friend ;)
Byron Whitlock
Good point.Anyway, I've tweaked it so there is a pause between launching an instance of IE and opening the target page, and now the target page at least shows up as a new tab, rather then a completely new IE window. It's not perfect, but it'll have to do for now.
A: 

Can you capture and display the return code from the ShellExecute? That might give us a clue as to what is happening.

result = ShellExecute(...

Possible return codes are listed here:

http://support.microsoft.com/kb/238245

It says in your question that you are hard-coding the CD-ROM drive letter. Does the machine you are testing on have a different drive letter than the one you created the CD on?

Robert Harvey
I'm actually using the path used to launch the executable to build the path for the .htm page. And since it works find with protected mode off, this isn't the problem.The return code, whether IE dissapears or not, is always 42. (Which is the normal success code for ShellExecute)