Solved

problem opening executable file while inside executable

Posted on 2002-04-17
5
197 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
  • 3
5 Comments
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Try

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

Author Comment

by:Ashurbanipal
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I already realized master-slave architecture with one Exe. I have no problem with this line:
FILE*     fp = fopen(ModuleName, "rb");
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

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 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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 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

12 Experts available now in Live!

Get 1:1 Help Now