关于readfile和writefile的问题 10
programpipe;useswindows;varr,w:handle;Security:TSecurityAttributes;z1,z2,Avail,BytesR...
program pipe;
uses windows;
var r,w:handle;
Security:TSecurityAttributes;
z1,z2,Avail,BytesRead:dword;
ri,oi: AnsiString;
begin
Security.nLength:= sizeof(SECURITY_ATTRIBUTES);
Security.lpSecurityDescriptor :=nil;
Security.bInheritHandle := TRUE;
CreatePipe(r,w,@Security ,256);
ri:='hello';
writeln(writefile(w,ri,length(ri),z1,nil),' ',z1);
ri:='ween';
writeln(writefile(w,ri,length(ri),z1,nil),' ',z1);
writeln(PeekNamedPipe(r, @oi, 100, @avail, nil, nil));
writeln(readfile(r,oi,avail,BytesRead,nil),' ',BytesRead);
writeln(oi);
closehandle(w);
closehandle(r);
readln;
end.这是我写的一个程序,为什么执行后我分两次写入的‘halloween’只能读出‘hallo’,麻烦大侠帮忙改一下,谢谢,一定要能成功的,最好能留个qq,谢了(虽然这是用pascal写的,但学c的应该能看懂吧)
writeln(readfile(r,oi,avail,BytesRead,nil),' ',BytesRead);
执行这条命令后BytesRead是9,但oi还是hallo 展开
uses windows;
var r,w:handle;
Security:TSecurityAttributes;
z1,z2,Avail,BytesRead:dword;
ri,oi: AnsiString;
begin
Security.nLength:= sizeof(SECURITY_ATTRIBUTES);
Security.lpSecurityDescriptor :=nil;
Security.bInheritHandle := TRUE;
CreatePipe(r,w,@Security ,256);
ri:='hello';
writeln(writefile(w,ri,length(ri),z1,nil),' ',z1);
ri:='ween';
writeln(writefile(w,ri,length(ri),z1,nil),' ',z1);
writeln(PeekNamedPipe(r, @oi, 100, @avail, nil, nil));
writeln(readfile(r,oi,avail,BytesRead,nil),' ',BytesRead);
writeln(oi);
closehandle(w);
closehandle(r);
readln;
end.这是我写的一个程序,为什么执行后我分两次写入的‘halloween’只能读出‘hallo’,麻烦大侠帮忙改一下,谢谢,一定要能成功的,最好能留个qq,谢了(虽然这是用pascal写的,但学c的应该能看懂吧)
writeln(readfile(r,oi,avail,BytesRead,nil),' ',BytesRead);
执行这条命令后BytesRead是9,但oi还是hallo 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询