Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Executing .EXE files.

Posted on 2000-04-21
10
Medium Priority
?
253 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
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

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.

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
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…
Suggested Courses

715 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