delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
用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;

posted on 2009-04-08 09:12 delphi2007 阅读(224) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。