有谁熟悉pipe API(120分)

  • 主题发起人 主题发起人 sprite
  • 开始时间 开始时间
S

sprite

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp;<br>用DELPHI写了一个重定向输出的程序 发现老有问题 <br> 程序如下  我想主要可能是在READFILE时出错 <br>&nbsp; &nbsp;可我一直查不出错<br>  望高手指教 不甚感激  <br>如?<br>procedure TForm1.Button1Click(Sender: TObject); <br>var ar: PSecurityAttributes; <br>&nbsp; &nbsp; handle_read,handle_write:thandle; <br>&nbsp; &nbsp; startinfo:tstartupinfo; <br>&nbsp; &nbsp; h:integer; <br>&nbsp; &nbsp; commandline,buffer:pchar; <br>&nbsp; &nbsp; pinfo:TProcessInformation; <br>&nbsp; &nbsp; bb:DWORD; <br>&nbsp; &nbsp; jud:boolean; <br>begin <br>&nbsp; &nbsp;new(ar); <br>&nbsp; &nbsp;ar^.nlength:=sizeof(SECURITY_ATTRIBUTES); <br>&nbsp; &nbsp;ar^.bInheritHandle:=true; <br>&nbsp; &nbsp;ar^.lpSecurityDescriptor:=nil; <br>&nbsp; &nbsp;if not createpipe(handle_read,handle_write,ar,1024) <br>&nbsp; &nbsp;then <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; showmessage('Eror pipe '); <br>&nbsp; &nbsp; &nbsp; exit; <br>&nbsp; &nbsp; &nbsp;end; <br>&nbsp; &nbsp;startinfo.cb:=sizeof(tstartupinfo); <br>&nbsp; &nbsp;getstartupinfo(startinfo); <br>&nbsp; &nbsp;startinfo.hStdOutput:=handle_write; <br>&nbsp; &nbsp;startinfo.hStdError:=handle_write; <br>&nbsp; &nbsp;startinfo.dwFlags:=STARTF_USESHOWWINDOW+ STARTF_USESTDHANDLES; <br>&nbsp; &nbsp;startinfo.wShowWindow:=SW_HIDE; <br>&nbsp; &nbsp;commandline:=pchar('masm first.asm');//命令行 <br>&nbsp; &nbsp;if not createprocess(nil,commandline,nil,nil,true,NORMAL_PRIORITY_CLASS,n <br>il,nil,startinfo,pinfo) <br>&nbsp; &nbsp; &nbsp;then <br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('Error process'); <br>&nbsp; &nbsp; &nbsp; &nbsp;exit; <br>&nbsp; &nbsp; &nbsp; &nbsp;end; <br>&nbsp; &nbsp; closehandle(handle_write); <br>&nbsp; &nbsp;getmem(buffer,1024); <br>&nbsp; &nbsp;buffer:='dfsfsg'; <br>&nbsp; &nbsp;jud:=true; <br>&nbsp; &nbsp; &nbsp; repeat <br>&nbsp; &nbsp; &nbsp; &nbsp;readfile(handle_read,buffer,1024,bb,nil) <br>&nbsp; &nbsp; &nbsp; &nbsp;sendmessage(memo1.handle,EM_REPLACESEL,wparam(false),lparam(buffer)); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if bb&lt;1023 then jud:=false; <br>&nbsp; &nbsp; &nbsp;until not jud ; <br>&nbsp; &nbsp; &nbsp; closehandle(handle_read); <br>&nbsp; &nbsp; &nbsp; freemem(buffer); <br>&nbsp; &nbsp; &nbsp; dispose(ar); <br>end;<br>&nbsp;
 
为什么没人回我 55~~
 
附加功能 &nbsp; 将问题提前 &nbsp; &nbsp;
 
sprite:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。<br>
 
都七月的了,<br>不打开真么readfile?是不是先该用createfile?
 
看300页msdn吧,解释不清楚的
 
这个问题我也想知道
 
sprite:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。<br><br>
 
多人接受答案了。
 
后退
顶部