Link to home
Start Free TrialLog in
Avatar of circuit
circuit

asked on

Spawning default web browser.

I am writing an MFC application under Windows 95.  My application generates
html files, and I would like to include a preview button which opens the user's
default web browser with a particular local html document.

I think there are two approaches to this problem:

1)  Look in the registry for the user's default web browser, then use spawnl() to launch it,
     sending the html file as a command-line argument.

2)  Somehow use the normal Windows mechanism for launching the appropriate
     application associated with a particular filetype.

My problem with (1), is that I don't know where in the registry to look for the
default web browser.

My problem with (2), is that I don't know how to access the normal Windows mechanism
for launching the application associated with a file extension.  spawnl() fails when asked
to execute an html file.

Thanks,
bre++
ASKER CERTIFIED SOLUTION
Avatar of lucidity
lucidity

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 circuit
circuit

ASKER

My email address is bl@pobox.com.  I tried the system call, but it just popped up an
MS-DOS window. Nothing happened after that.  I'd appreciate it if I could look at
your http launcher code.
I need your email address then. And the system call does work, if your browser it installed properly and you make the call properly : I think you might have to spend a little more then 20 minutes on it.
Avatar of circuit

ASKER

My email address is included in the previous comment.  It is: bl@pobox.com.

I made the system call exactly as you stated it, except with "system" (lower-case 's')
as documented in the Visual C++ help files.  My browser is installed correctly,
and the command does work correctly from the MS-DOS prompt.  It does not
work correctly from within my application.  I am not able to get back an error code,
because execution never returns to my program.

I have also tried:
_spawnl (_P_NOWAIT,"c:\\windows\\command\\Start","page.html",NULL);

thinking that perhaps the start command was executing in the same process as my
application.  But, the above didn't work either.

bre++

Avatar of circuit

ASKER

Strange, if I execute the "start page.html" from the MS-DOS prompt, my browser pops up immediately.  From my application, you're right the system ("start page.html") does work, but it takes a lot longer (I had to wait about a minute).  Anyway, I look forward to seeing your hyperlink code.  I can't have a big ugly DOS window pop up, and then a 1 minute wait for the application that I'm writing.

Thanks again,
bre++
bl@pobox.com
http://209.66.99.126/controls/hyperlinkex.shtml

Actually I remembered what page it was on, heres the link

good luck.