C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 8th, 2002, 07:30 AM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Calling another program

Have a question...

How do you call another .exe from within a command line program so that I can pass it parameters?

Eric

Reply With Quote
  #2  
Old November 8th, 2002, 12:42 PM
jonsagara's Avatar
jonsagara jonsagara is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: USA
Posts: 286 jonsagara User rank is Private First Class (20 - 50 Reputation Level)jonsagara User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 m 23 sec
Reputation Power: 12
CreateProcess() ought to do it.
__________________
Jon Sagara

"Me fail English? That's unpossible!"

Reply With Quote
  #3  
Old November 8th, 2002, 01:01 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
you can use the imho easier function ShellExecute from shell32.dll.
the syntax (from the MS Windows SDK) is:
Code:
HINSTANCE ShellExecute(
    HWND hwnd,	// handle to parent window
    LPCTSTR lpOperation,	// pointer to string that specifies operation to perform
    LPCTSTR lpFile,	// pointer to filename or folder name string
    LPCTSTR lpParameters,	// pointer to string that specifies executable-file parameters 
    LPCTSTR lpDirectory,	// pointer to string that specifies default directory
    INT nShowCmd 	// whether file is shown when opened
   );

[edit]
the only thing that was unclear to me first was "lpOperation" which should be "open"
[/edit]
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Last edited by M.Hirsch : November 8th, 2002 at 01:10 PM.

Reply With Quote
  #4  
Old November 8th, 2002, 01:03 PM
ClayDowling ClayDowling is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Flint, MI
Posts: 328 ClayDowling User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 25 sec
Reputation Power: 11
A portable solution would be to use popen, which allows complete command line option passing. It's generally part of stdio.h in modern compilers. As a bonus the input and output are available to the calling program.

If you want the program to present it's interface to the end user, the aforementioned CreateProcess is the way to go.
__________________
Clay Dowling
Lazarus Notes
Articles and commentary on web development
http://www.lazarusid.com/notes/

Reply With Quote
  #5  
Old November 8th, 2002, 07:18 PM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks guys. I'll try to get working on these tonight if I can scrape time away from my daughter.

Eric

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Calling another program

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap