Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

problem opening executable file while inside executable

Posted on 2002-04-17
5
Medium Priority
?
250 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
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

971 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