Solved

Executing .EXE files.

Posted on 2000-04-21
10
243 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

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

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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

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

13 Experts available now in Live!

Get 1:1 Help Now