S
sprite
Unregistered / Unconfirmed
GUEST, unregistred user!
<br>用DELPHI写了一个重定向输出的程序 发现老有问题 <br> 程序如下 我想主要可能是在READFILE时出错 <br> 可我一直查不出错<br> 望高手指教 不甚感激 <br>如?<br>procedure TForm1.Button1Click(Sender: TObject); <br>var ar: PSecurityAttributes; <br> handle_read,handle_write:thandle; <br> startinfo:tstartupinfo; <br> h:integer; <br> commandline,bufferchar; <br> pinfo:TProcessInformation; <br> bbWORD; <br> jud:boolean; <br>begin <br> new(ar); <br> ar^.nlength:=sizeof(SECURITY_ATTRIBUTES); <br> ar^.bInheritHandle:=true; <br> ar^.lpSecurityDescriptor:=nil; <br> if not createpipe(handle_read,handle_write,ar,1024) <br> then <br> begin <br> showmessage('Eror pipe '); <br> exit; <br> end; <br> startinfo.cb:=sizeof(tstartupinfo); <br> getstartupinfo(startinfo); <br> startinfo.hStdOutput:=handle_write; <br> startinfo.hStdError:=handle_write; <br> startinfo.dwFlags:=STARTF_USESHOWWINDOW+ STARTF_USESTDHANDLES; <br> startinfo.wShowWindow:=SW_HIDE; <br> commandline:=pchar('masm first.asm');//命令行 <br> if not createprocess(nil,commandline,nil,nil,true,NORMAL_PRIORITY_CLASS,n <br>il,nil,startinfo,pinfo) <br> then <br> begin <br> showmessage('Error process'); <br> exit; <br> end; <br> closehandle(handle_write); <br> getmem(buffer,1024); <br> buffer:='dfsfsg'; <br> jud:=true; <br> repeat <br> readfile(handle_read,buffer,1024,bb,nil) <br> sendmessage(memo1.handle,EM_REPLACESEL,wparam(false),lparam(buffer)); <br> if bb<1023 then jud:=false; <br> until not jud ; <br> closehandle(handle_read); <br> freemem(buffer); <br> dispose(ar); <br>end;<br>