Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Spawning default web browser.

Posted on 1998-05-08
6
Medium Priority
?
233 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 300 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 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