Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Executing .EXE files.

Posted on 2000-04-21
10
Medium Priority
?
257 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 400 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

879 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