Solved

Executing .EXE files.

Posted on 2000-04-21
10
250 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
Independent Software Vendors: 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

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