Solved

Opening HTML files in C++ so that they open the browser that the user has on their system

Posted on 1999-01-15
12
159 Views
Last Modified: 2010-04-02
I am tring to write a programm in C++ that will automatically open my web page (from a disk), all i want to do is set it up so that the user has the option to open the web page in an off line mode and veiw the web page in their browser without them manually opening their browser.
Please help
Cheers
Spider.
0
Comment
Question by:shu96mjw
[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
  • 5
  • 4
  • 3
12 Comments
 

Author Comment

by:shu96mjw
ID: 1182283
Is it something to do with the DOS library,
Is it possible to do it in C++ Builder instead
0
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 1182284
For a windows program you can use WinExec() or CreateProcess() to start your brownser from a C++ program.  Let me know if you have any questions.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1182285
In a non windows C++ program you can use the system() function or any of the execxx() spawnxx() functions.  (The xx are letters that can change as there are several variations of these functions..)
0
Technology Partners: 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!

 
LVL 10

Expert Comment

by:viktornet
ID: 1182286
The best and easier way to do it is as follows, especially when using C++ Builder...

ShellExecute(0, "open", "C:\\MyPath\\MyTestPage.html", NULL, NULL, SW_SHOWNORMAL);

That's the easier way to do it and your page would be open in your defaul browser... For example I use Netscape and it would open it in Netscape... If oyu use IE it would open it in IE.... That's the easiest and best way,,,

Let me know if you need more help....

-Viktor
--Ivanov
0
 

Author Comment

by:shu96mjw
ID: 1182287
Cheers but Viktornets answer proved the most succsesful.

Ever in Debt ( as long as it is not monitory!)
0
 
LVL 22

Expert Comment

by:nietod
ID: 1182288
Then you could have rejected my answer to let  him submit a dummy answer.  

The advantage to  ShellExecute is that it uses the user's "default brownser", that is, whatever they want to use as a default.  The dissadvantage is that you have no control over this program.  so if your application needs to pass parameters to the browser, that is not possible, if you need to monitor is progrress or position its windows, that is not really possible.   Which is best really just depends on what your needs are.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1182289
Well, I was hoping to get my points 'cuz if my answer was correct.. and in this case it was, so i'm a little disappointed...

YOu can pass parameters to ShellExecute() and you can even make ShellExecute() e-mail something from a Text Component like Rich Edit, Edit Box, Memo and so on....

ShellExecute(0m "open", "mailto:viktor@megsinet.net", "The Subject Goes here", NULL, SW_NORMAL);

Hope this helps...

-Viktor
--Ivanov
0
 
LVL 22

Expert Comment

by:nietod
ID: 1182290
Realistically, you can't send parameters to ShellExecute() because you don't know what program will be run, so you don't know what parameters to send.  Unless you know that all programs of a particular type will take some sort of standard parameter.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1182291
usually the browsers have the S command to send, so you can use it with ShellExecute().. so I think ShellExecute() can do almost anything you want.... well almost :)
0
 

Author Comment

by:shu96mjw
ID: 1182292
Very sorry nietid if I offended you, I didnt realise that I should pass the points to the supplier of the most useful answer, so I shall now like to ask a straight forward question, to viktornet.  Hopefully it will gain Viktornet some points, and also prove to the others that I appear to have a real problem with this area.

Q:  In which library is ShellExecute and does it return a false  or error if the file is not opened correctly, if at all?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1182293
not offended, but viktornet probably feels a little cheated, it was his idea.  Try to make sure the right person gets the points in the future.

ShellExecute is not in a library.  It is part of the window API.  It returns a non-zero value when it is able to run a process to open the file.  It returns zero if there is a problem.  It is documented in the windows help, look there.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1182294
what nietod said about ShellExecute() is completely correct...
0

Featured Post

Technology Partners: 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 This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

749 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