Solved

File opening problem

Posted on 2004-08-13
8
331 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.

773 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