Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Executing program with parameters

Posted on 2002-07-07
4
Medium Priority
?
188 Views
Last Modified: 2010-04-04
Hi,

I'm trying to execute an external program with the shellexecute API. The exteranal program needs rather a lot of parameters in order to run correctly however; i.e. c:\dir\progname.exe -para1 -para2 etc.

How can I do this in Delphi? Idealy my program will generate the parameters at run time.

Thanks,

BTW, the external program is xplanet - a you can find more information at http://xplanet.sourceforge.net. I'm attempting to create a small [simple] launcher for it.
0
Comment
Question by:alza
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7135532
Hi alza,

look in the help for samples on  paramcount and paramstr for this

HAGD:O)Bruintje
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 150 total points
ID: 7135759
hello alza, you could try something like this -
add ShellApi to your uses clause

implementation

uses ShellApi

var
ExePath, SendParam: String;
begin

  ExePath := 'C:\Folder\Exe.exe'
  SendParam := Param1+' '+Param2+' '+Param3;

  ShellExecute(Handle,
'open',     // pointer to string that specifies operation to perform
    PChar(ExePath),     // pointer to filename or folder name string
    PChar(SendParam),     // pointer to string that specifies executable-file parameters
    nil,     // pointer to string that specifies default directory
    SW_SHOW      // whether file is shown when opened
   );

end;
0
 

Author Comment

by:alza
ID: 7135800
Hello and thank you to you both.

Slick812;
I've implemented a simple edit box where the parameters can be entered and then assigned to a string (SendParam). This seems to work fine at the moment.

bruintje;
I'm not entirley sure how and where the functions you've mentioned come into it. I've tried using paramstr(0) and this just returns the path of my compiled program...

Thanks,
0
 
LVL 1

Expert Comment

by:herr_apfelschnitt
ID: 7136034
paramstr contains parameters that were used to run the current program, where paramstr(0) (the first one) contains the executable name.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 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