Link to home
Start Free TrialLog in
Avatar of crysallus
crysallusFlag for Australia

asked on

Peculiar error when opening html file from DVD in Internet Explorer using ShellExecuteEx

Hi,

My first question, so apologies if I've done something wrong. Still learning the ropes around here.

Anyway, here's what I'm trying to do.

I have a DVD that contains both normal DVD content (video in VIDEO_TS folder), as well as a bunch of html pages containing extra informational resources. To make it as easy as possible for the end users, I've written a small launching program that just contains 2 buttons, one to launch a DVD player to play the DVD, the other to open the front page for the html content. This launching program is set to autorun in an autorun.inf file.

And it all works fine except for the opening of the html front page when:

- it's being run from a DVD (and not from a usb thumb drive during testing)
- Internet Explorer is the default web browser (consequently it's the browser being used to open the html file)
- and IE isn't already open when the launcher program attempts to open the html file.

In all other scenarios it works perfectly. Testing from a thumb drive, it always works. From the DVD, any other web browser (Firefox, Chrome, Opera, Safari have all been tested) works fine. If IE is open before the launching program attempts to open the html file, it works as well. Just not from the DVD, using IE, when IE isn't already open. In that case, on my vista machine, IE closes instantly, no errors, messages boxes, nothing. On another windows 7 machine, it just sits there with 'Connecting...' in the tab title, and does nothing. In both cases it's IE 8.

My launching program is a Win32 project written using Visual C++ Express 2008. To open the html file it uses ShellExecuteEx, as follows (minus some error handling unneeded for this post):

SHELLEXECUTEINFOW info;
info.cbSize = sizeof(SHELLEXECUTEINFOW);
info.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC;
info.hwnd = NULL;
info.lpVerb = L"open";
info.lpFile = filename;
info.lpParameters = NULL;
info.lpDirectory = NULL;
info.nShow = SW_SHOWNORMAL;

ShellExecuteExW(&info);

filename is a LPCWSTR being passed to the function containing the code above. It contains the full path of the html file to open, including the correct drive letter which has been determined by earlier code. I know that ShellExecuteExW is returning successfully, because if it doesn't, a message box appears indicating an error has occurred (I left that bit out above for clarity).

The launching program terminates very soon after this call, hence the SEE_MASK_NOASYNC flag, though I've done this mostly because msdn said to, not so much because I understand completely the reason for it, apart from the brief msdn explanation.

COM is also being initialised according the msdn documentation for ShellExecute.

If anyone has any clues on this, that would be most appreciated.
SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crysallus

ASKER

Yes, you're right. It runs properly when I run it with admin privileges.

Is there anyway to get around this to enable it to run properly with IE without requiring admin privileges? A different strategy perhaps? I'd really prefer it if our end users didn't have to confirm that the application can run in the extra dialog window if possible.

If not, is it possible to have the program elevate it's privileges if it detects IE is the default browser, so that it's only needed for IE users, and other users don't have to confirm the dialog window? Perhaps another small program which runs to start with to detect whether IE is being used, then runs the launcher application with or without admin privileges accordingly?
Actually, just given this a bit more thought. I think I know how to do the second option of only launching a version of the application with admin privileges if IE is detected, so, at least for now, I don't need help on that one (though I'll wait until I actually try it before confirming that).

I would still welcome any suggestions as to how to avoid requiring admin privileges at all though.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks SriVaddadi for the tip. You definitely saved me some debugging time. I'm giving it a B as it wasn't really a satisfactory solution to my problem, unlike the alternative solution I outlined in my last post.