when you call an application for the first time you should call the sw_shownormal flag.
using shellexecute
the following is a list of shellexecute uses. you will need to add the windows and shellapi units to the uses clause.
run an application called demo.exe in "c:\apps" directory:
shellexecute(handle,nil,pchar('c:\apps\demo.exe'), nil,nil,sw_shownormal);
open a file (e.g. "log.txt"):
shellexecute(handle,'open',pchar('c:\log.txt'), nil,nil,sw_shownormal);
play a music file (e.g. "ending.mp3"):
shellexecute(handle,'play',pchar('c:\ending.mp3'), nil,nil,sw_shownormal);
print a log file (e.g. "log.txt"):
shellexecute(handle,'print',pchar('c:\log.txt'), nil,nil,sw_shownormal);
open up windows explorer on c drive (e.g. "c:"):
shellexecute(handle,'explore',pchar('c:\'), nil,nil,sw_shownormal);
create a new email message with outlook or outlook express:
procedure createemail(const emailaddr, subject, body: string);
var
concatemailstr: string;
begin
concatemailstr := emailaddr + '?subject=' + subject + '&body=' + body;
shellexecute(handle,'open',pchar(concatemailstr), nil, nil, sw_shownormal);
end;
conclusion
i hope this article has provided you with a greater insight into running applications from delphi and the shellexecute winapi function. in the next article i will discuss how to wait for an application to finish before resuming application execution.
further reading
for further information on the shellexecute winapi function refer to the msdn online library: