用createprocess执行word,需要为外部程序指定一个叁数'd:\aaa.doc',如果这个文档是stringlist中的某一项,那么该如何写呢? Delphi / Windows SDK/APIhttp://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;