?
Solved

File opening problem

Posted on 2004-08-13
8
Medium Priority
?
337 Views
Last Modified: 2010-05-18
Hi
I've  got the following problem:

if I want to programmatically open for example a .BMP file with ITS applicaion (MS Paint) I use the command:
system ("picture.BMP");

Though I get a black DOS-window (cmd.exe) too, it works well.
But when I want to open a .HTM file with Internet Explorer it doesn't work- I only get the black window and Internet Explorer doesn't run. (.HTM files are attatched to IE on my computer)
I could use
WinExec ("C:\\Programme\\Internet Explorer\\IEXPLORE.EXE website.htm", SW_RESTORE);
but the path to the Internet Explorer isn't the same on all computers...
0
Comment
Question by:MegaEnforcerBoy
[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
8 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 170 total points
ID: 11795450
Use

ShellExecute(NULL,"open", "website.htm", NULL, NULL, SW_SHOW);

instead.
0
 
LVL 3

Expert Comment

by:gillgates
ID: 11796709
I believe you could just do...

WinExec ("IEXPLORE.EXE website.htm", SW_RESTORE);

king of like typeing iexplore.exe from the run menu
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:MegaEnforcerBoy
ID: 11799800
thanks a lot
jkr will get the points because he was the first one who posted the right answer;
but could you tell me first, why only ShellExecute works, though there are many other functions, such as _swanl, _execl, WinExec, system and maybe some other, which partially even cause a syntax error and some of them don't work correctly? Actually they must solve the same problem, so what's the difference between them?
thanks
0
 
LVL 2

Expert Comment

by:dimitry_dimitry
ID: 11800464
Quote from MSDN:
If the executable or path name has a space in it, there is a risk that a different executable could be run because of the way the function parses spaces.

Also as I think WinExec accepts parameters, as there is an example of such use:
WinExec("\"C:\\Program Files\\MyApp.exe\" -L -S", ...)
Note that WinExec exists for compatibility.
0
 
LVL 1

Author Comment

by:MegaEnforcerBoy
ID: 11829548
you didn't answer my question.. well, maybe the answer is not that easy. but i accept your answer
0
 
LVL 86

Expert Comment

by:jkr
ID: 11831190
>>you didn't answer my question..

Um, what else then? You wanted to open a HTML page with IE, and that's what it does. Nothing else.
0
 
LVL 1

Author Comment

by:MegaEnforcerBoy
ID: 11840352
that's all right, I mean my second question- right after gillgates' comment- what's the difference between all these numerous functions/why some of them don't work.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

762 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