Solved

problem opening executable file while inside executable

Posted on 2002-04-17
5
236 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 100 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

738 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