Solved

Spawning default web browser.

Posted on 1998-05-08
6
227 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 144
ASCII Non-Printable characters/codes and their HTML equivalents 6 104
only14 challenge 19 68
twoTwo  challenge 35 92
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now