Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

problem opening executable file while inside executable

Posted on 2002-04-17
5
Medium Priority
?
244 Views
Last Modified: 2010-04-02
Inside a given a program c:\program.exe, I have the following code:

filebuf *fb=new filebuf;
int mode=ios::binary | ios::in | ios::nocreate;
fb->open("c:\program.exe",mode);
if (!fb->is_open())
  and this test always fails

Is the operating system blocking me on this?  Is there some way to copy the executable to another file and open that?

Thanks
0
Comment
Question by:Ashurbanipal
[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
  • 3
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6947907
Try

fb->open("c:\\program.exe",mode); // note the double backslash!
0
 

Author Comment

by:Ashurbanipal
ID: 6947967
actually the code looks more like:

std::string file=GetCommandLine();
fb->open(file.c_str(),mode);

When I look at the contents of "file" there doesn't seem to be any problem.  I'm opening other files with no problem and am just having a problem with the executable.
0
 
LVL 16

Accepted Solution

by:
AlexNek earned 300 total points
ID: 6948036
I already realized master-slave architecture with one Exe. I have no problem with this line:
FILE*     fp = fopen(ModuleName, "rb");
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 6948264
I already realized master-slave architecture with one Exe. I have no problem with this line:
FILE*     fp = fopen(ModuleName, "rb");
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 6948519
I already realized master-slave architecture with one Exe. I have no problem with this line:
FILE*     fp = fopen(ModuleName, "rb");
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

670 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