Solved

How to execute other application in delphi3

Posted on 1998-10-12
3
157 Views
Last Modified: 2010-04-06
Can you tell me about how to execute other application in
delphi 3
0
Comment
Question by:tanad
3 Comments
 
LVL 3

Accepted Solution

by:
philipleighs earned 50 total points
ID: 1342612
Hi,

WinExec(PathName, SW_SHOW)

or

ShellExecute(...

I may have the parameters wrong so check in Delphi help

Cheers,
Phil.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1342613
Example for ShellExecute() would be

ShellExecute(0, 'open', PathName, nil, nil, SW_SHOWNORMAL);//Take a look at the parameters because I same as Phil am not sure if I haven't missed maybe one parameter :->

Regards,
Viktor Ivanov
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1342614
and in addition i want to state:

if you put uses fmxutils in your header you can access the function ExecuteFile from delphi. this one "encapsulates" ShellExecute from the win api.

function ExecuteFile(const FileName, Params, DefaultDir: string; ShowCmd: Integer): THandle;

an example for a call:

const
  sCmdPar = '-a -&f -ex -P a:\pizzadb.zip';

procedure TForm1.SpeedButton2Click(Sender: TObject);
var
  sDataPath: string;
begin
  if not DirectoryExists(Edit1.Text) then begin
    MessageDlg('Directory ''' + Edit1.Text + ''' does not exist',
      mtError, [mbOk], 0);
    ActiveControl := Edit1;
    Exit;
  end;
  sDataPath := Edit1.Text;
  if Copy(sDataPath, Length(sDataPath), 1) <> '\' then
    sDataPath := sDataPath + '\';
  if MessageDlg('Insert a disk in drive A: and press RETURN.:', mtInformation, [mbOk, mbCancel], 0) = mrCancel then
    Exit;
  if not DirectoryExists('A:\') then begin
    MessageDlg('no disk present in drive A:', mtError, [mbOk], 0);
    Exit;
  end;
  ExecuteFile('PKZIP.EXE', sCmdPar + ' ' + sDataPath + '*.*', ExtractFilePath(Application.ExeName), SW_SHOWNORMAL);
end;

with this function you ain't got full control of the process and it's threads regarding security, environment, priority etc. but i think that was not what you've got in mind anyway.

if this one shouldn't be sufficient, tell us.

regs,

Black Death.

0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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