Solved

Executing .EXE files.

Posted on 2000-04-21
10
248 Views
Last Modified: 2010-04-04
Hi everybody.
I want, as I said in title, to execute a .EXE file. I tried ExecuteFile as the Help says, but the function is unknown. I must probably write something in the uses clause. What?
Anticipated thanks, Alex.
0
Comment
Question by:val84
[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
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 2

Expert Comment

by:DidierD
ID: 2737312
use WinExec('C:\windows\notepad.exe', SW_SHOWNORMAL);
0
 
LVL 4

Expert Comment

by:jeurk
ID: 2737320
hello,
to make it simple use
WinExec(PChar('notepad.exe'), SW_SHOW);
for exemple
0
 
LVL 4

Expert Comment

by:jeurk
ID: 2737323
;), to late ...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2737333
hi val84,

this fuction is in the unit fmxutils, somewhere in the demo-dir of delphi,
just pasted

function ExecuteFile(const FileName, Params, DefaultDir: string;
  ShowCmd: Integer): THandle;
var
  zFileName, zParams, zDir: array[0..79] of Char;
begin
  Result := ShellExecute(Application.MainForm.Handle, nil,
    StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
    StrPCopy(zDir, DefaultDir), ShowCmd);
end;

meikl
0
 

Author Comment

by:val84
ID: 2737342
It works, thanks both of you.
Alex.
0
 

Author Comment

by:val84
ID: 2737360
It works, thanks both of you.
Alex.
0
 
LVL 2

Expert Comment

by:DidierD
ID: 2737362
val84,

If you liked an answer, can you grade it then. You can accept a comment as an answer.

Didier
0
 

Author Comment

by:val84
ID: 2737368
Hi Didier,
Your answer is fine, but I don't see a button to accept it, so I accept it in written form.

Hi Kretzschmar,
Thanks for your comment. Which is the difference between ExecuteFile and WinExec?
Alex.
0
 
LVL 2

Accepted Solution

by:
DidierD earned 100 total points
ID: 2737378
val84,

There's a button in the green bar of the comment on the right site. Because you liked my answer i will post this as an answer.

Didier.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2737385
hi val84,

the difference is, that the executefile calls a shellexecute, therefore you can give a filename, and the associated exe is called and opens the given filename (don't forget to add shellapi in the uses clause).

sample

function ExecuteFile(const FileName, Params, DefaultDir: string;
  ShowCmd: Integer): THandle;
var
  zFileName, zParams, zDir: array[0..79] of Char;
begin
  Result := ShellExecute(Application.MainForm.Handle, nil,
    StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
    StrPCopy(zDir, DefaultDir), ShowCmd);
end;


procedure TForm1.Button1Click(Sender: TObject);
var AHandle : THandle;
begin
  AHandle := ExecuteFile('c:\bmp1.bmp','','',sw_show);
end;

will open paint(if it associated with .bmp) and paint opens the file bmp1.bmp.

meikl
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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