您的位置:首页 > 其它

用createprocess执行word,需要为外部程序指定一个叁数'd:\aaa.doc',如果这个文档是stringlist中的某一项,那么该如何写呢?

2009-04-08 09:16 796 查看
用createprocess执行word,需要为外部程序指定一个叁数'd:\aaa.doc',如果这个文档是stringlist中的某一项,那么该如何写呢? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiAPI/html/delphi_20061106182559294.html

var
x:integer;
wordlist:tstringlist;
si:startupinfor;
pi:process_information;

begin
wordlist:=tstringlist.create;
wordlist.add(....);

for x:=1 to wordlist.count do begin
createprocess(nil,'d:\office\word.exe wordlist[x-1]',nil,nil,false,0,nil,nil,si,pi);
end;

end;

调试半天,总是不成功,如何妆wordlist中和doc文档作为word.exe的参数来传递呢?

这样试试:

var
x:integer;
wordlist:tstringlist;
si:startupinfor;
pi:process_information;

sRun:String;//定义一个临时变量

begin
wordlist:=tstringlist.create;
wordlist.add(....);

for x:=1 to wordlist.count do
begin
sRun := 'd:\office\word.exe '+wordlist[x-1];
createprocess(nil,Pchar(sRun),nil,nil,false,0,nil,nil,si,pi);
end;

end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐