Solved

File opening problem

Posted on 2004-08-13
8
332 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
8 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 85 total points
ID: 11795450
Use

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

instead.
0
 
LVL 3

Expert Comment

by:pulupul
ID: 11795453
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

820 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