Solved

File opening problem

Posted on 2004-08-13
8
329 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now