Solved

Spawning default web browser.

Posted on 1998-05-08
6
230 Views
Last Modified: 2013-11-20
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++
0
Comment
Question by:circuit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 2

Accepted Solution

by:
lucidity earned 100 total points
ID: 1308449
I have some source for a hyperlink class where you can specify a html hyperlink and all you have to worry about is where it points to, could be local file:\\ or a http:\\. give me your email and I can sent it.

or, the caveman way would be to :
System("Start http://www.microsoft.com");
or
System("Start c:\page.html");
0
 

Author Comment

by:circuit
ID: 1308450
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.
0
 
LVL 2

Expert Comment

by:lucidity
ID: 1308451
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:circuit
ID: 1308452
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++

0
 

Author Comment

by:circuit
ID: 1308453
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
0
 
LVL 2

Expert Comment

by:lucidity
ID: 1308454
http://209.66.99.126/controls/hyperlinkex.shtml

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

good luck.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question