W
wp231957
Unregistered / Unconfirmed
GUEST, unregistred user!
//替换回车为空格<br>function replacern(hfile:thandle):dword;<br>const rn:string=#13#10;<br>const sp:string=#20;<br>var<br> readbuffer:string;<br> filesize:integer;<br> numberofbytesrw:dword;<br> i,j,firstrn:integer;<br>begin<br> i:=0;<br> j:=0;<br> firstrn:=0;<br> result:=0;<br> setfilepointer(hfile,0,nil,file_begin);<br> filesize:=getfilesize(hfile,nil);<br> SetLength(readbuffer,2);<br> while i<filesize do begin<br> readfile(hfile,readbuffer[1],sizeof(readbuffer),numberofbytesrw,nil);<br> if (readbuffer[1]=#13) and (readbuffer[2]=#10) then begin<br> result:=i;<br> inc(j);<br> if j=1 then begin<br> firstrn:=i; //记录第一个回车的位置<br> end;<br> if j>1 then begin<br> if ((result-7) mod firstrn)<>0 then begin 如果其他回车位置不符合第一回车的位置,那么就写入空格字符<br> writefile(hfile,sp[1],4,numberofbytesrw,nil);<br> end;<br> end;<br> end;<br> inc(i,2);<br> end;<br><br>end;