How do you start a exe file?

Hello guys i know i don't have many points mut how do i start exe files from delphi?
Thanks!!
LVL 1
dvd99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MotazCommented:
Use this API function:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShellExecute(handle, 'open', 'Notepad', nil, nil, sw_Normal);
end;

but make sure to add ShellApi to uses clause.

Comment:

You can also open any document using this function such as .doc file, .htm and any registered extention

Motaz
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MotazCommented:

another example:

  ShellExecute(handle, 'open', 'c:\windows\Notepad.exe', 'Test.txt', 'c:\my documents', sw_Normal);

- 'Test.txt' is the parameter you want to pass to application.

- 'c:\My Documents' is the directory in wich your application will be started (It will be it's default directory).

- sw_Normal, the mode of showing application Windows, can be:
  sw_Normal
  sw_ShowMaximized
  sw_ShowMinimized
  sw_Restore
  sw_Hide



Motaz
0
craig_capelCommented:
Ok a better way is this....


winexec('filename.exe',1);

so winexec('c:\windows\notepad.exe',1); {will execute notepad}
     winexec('c:\windows\calc.exe',1); {will execute calculator}
     winexec('c:\command.com',1);   {Command Prompt}

Hope that is easier


Craig C.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

edeyCommented:
there is also the createProcess api, which (when combined with the waitForSingleObject api) allows you to wait for the exe to finish

GL
Mike
0
craig_capelCommented:
had a look, seems easier to get hold of the handle on startup... and wait for it to not exist?
0
dvd99Author Commented:
Thanks Motaz and thanks craig_capel  and thanks to edey . Is winexec a windows api that can be used with VB or J++? , Just wondering
0
craig_capelCommented:
yes it is
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.