Solved

Spawning default web browser.

Posted on 1998-05-08
6
226 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:circuit
Comment Utility
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
Comment Utility
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
Comment Utility
http://209.66.99.126/controls/hyperlinkex.shtml

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

good luck.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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