?
Solved

Executing program with parameters

Posted on 2002-07-07
4
Medium Priority
?
186 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
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

800 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