Solved

How to execute other application in delphi3

Posted on 1998-10-12
3
155 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now