[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 133
  • Last Modified:

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!!
0
dvd99
Asked:
dvd99
1 Solution
 
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
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now