p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > C# and C > C++ and Visual C++ > C++ Programming
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 14th, 2005, 06:54 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: Lahore, punjab, Pakistan.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default can i run exe file from c or c++ code

can i run any exe file form c or c++ languge code

shafiq
__________________
shafiq
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 22nd, 2005, 12:47 PM
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2004
Location: , NY, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ealkurabi
Default

what kinda question is that?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old March 22nd, 2005, 06:52 PM
Authorized User
Points: 31, Level: 1
Points: 31, Level: 1 Points: 31, Level: 1 Points: 31, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Magdeburg, Saxony Anhalt, Germany.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old March 23rd, 2005, 07:15 PM
Registered User
Points: 14, Level: 1
Points: 14, Level: 1 Points: 14, Level: 1 Points: 14, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do you mean injecting and exe file into your program?
If so then google it.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old April 7th, 2005, 02:06 PM
Friend of Wrox
Points: 1,424, Level: 15
Points: 1,424, Level: 15 Points: 1,424, Level: 15 Points: 1,424, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 464
Thanks: 0
Thanked 2 Times in 2 Posts
Default

system ("prog.exe");

HTH

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old April 16th, 2005, 12:44 PM
Authorized User
Points: 125, Level: 2
Points: 125, Level: 2 Points: 125, Level: 2 Points: 125, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to merediths
Default


 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old April 18th, 2005, 08:01 AM
Authorized User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: Zagreb, , Croatia.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old April 19th, 2005, 11:08 AM
Friend of Wrox
Points: 1,424, Level: 15
Points: 1,424, Level: 15 Points: 1,424, Level: 15 Points: 1,424, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 464
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
run .exe in asp hostxxi Classic ASP Basics 0 June 18th, 2008 05:01 AM
How can i code to download an exe file??? RinoDM HTML Code Clinic 1 May 25th, 2008 06:16 PM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 06:44 AM
how to run exe file from ASP? Andraw Classic ASP Basics 1 September 23rd, 2005 07:32 AM
Run an exe julesmel C# 1 August 6th, 2003 11:53 AM



All times are GMT -4. The time now is 04:05 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc