|
|
 |
| C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C++ Programming section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 14th, 2005, 06:54 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Location: Lahore, punjab, Pakistan.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
can i run exe file from c or c++ code
can i run any exe file form c or c++ languge code
shafiq
__________________
shafiq
|

March 22nd, 2005, 12:47 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Location: , NY, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
what kinda question is that?
|

March 22nd, 2005, 06:52 PM
|
|
Authorized User
|
|
Join Date: Jan 2005
Location: Magdeburg, Saxony Anhalt, Germany.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi ...
i really dont understand what is ur question ???
but why do u need to run a exe file using c coding ...if u want to result that exe file(if its a c/c++ coding) then u can use it as the header file in ur c program ...
ur question is incomplete ...
|

March 23rd, 2005, 07:15 PM
|
|
Registered User
|
|
Join Date: Mar 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Do you mean injecting and exe file into your program?
If so then google it.
|

April 7th, 2005, 02:06 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 464
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
system ("prog.exe");
HTH
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com
|

April 16th, 2005, 12:44 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
system("prog.exe") is great if you don't care about the input/output of the program. You might also want to look into the 'popen()' function -- popen() lets you get a file descriptor so you can read or write to the programs standard input/output. For example, you could popen('ftp.exe') and write ftp commands to it using fputs or whatever, or popen('top') and read process information from the 'top' command just like it was a file.
Regards,
Meredith Shaebanyan
|

April 18th, 2005, 08:01 AM
|
|
Authorized User
|
|
Join Date: Mar 2005
Location: Zagreb, , Croatia.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi merediths
could you give me a good example on what you just said in your post!!!
This is very impressive answer you gave here, and this is perhaps just
the right thing i need!!!
But in code not words :-)
But don't be to mean with code, something simple will do just fine,
just to see how it works!
Perhaps example with "ftp.exe" would be good.
C or C++ code, it doesn't matter
greetings: icopec
from : Croatia
|

April 19th, 2005, 11:08 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 464
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Hey Merediths,
Yah, but popen isn't part of ANSI C, and shafiq (I'm guessing) is on a windoze system. I'm not sure if windows supports popen(), as you're essentially opening a UNIX pipe. Anyhow, here's a bit of demo code. Works on Linux, YMMV.
/*
* Purpose: Program to demonstrate the popen function.
*
* to do: Check that the 'popen' was successfull.
*
* Author: M J Leslie.
* Date: 08-Jan-94
*/
#include <stdio.h>
main()
{
FILE *fp;
char line[130]; /* line of data from unix command*/
fp = popen("ls -l", "r"); /* Issue the command. */
/* Read a line */
while ( fgets( line, sizeof line, fp))
{
printf("%s", line);
}
pclose(fp);
}
HTH
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |