Running applications from DelphiTM: Using ShellExecute (Part 1) {转贴}[3]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 ihihonline 的 blog

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:

microsoft msdn - shellexecute



本文关键:Running applications from DelphiTM: Using ShellExecute (Part 1) {转贴}
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top