全
全文检索
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button3Click(Sender: TObject);<br> var<br> f:cardinal;<br> textsize:longint;<br> bytesred:dword;<br> thetextchar;<br> s:string;<br> begin<br> f:=createfile('c:/1.txt',generic_read,file_share_read or file_share_write,<br> nil,open_always,file_attribute_normal,0);<br><br> //获得文档中文本占据的字节数<br> readfile(f,textsize,sizeof(textsize),bytesred,nil);<br> //为thetext分配内存<br> getmem(thetext,textsize);<br> // 初始化缓冲区<br> fillmemory(thetext,textsize,0);<br> //设置指针<br> setfilepointer(f,sizeof(textsize),nil,file_begin);<br> //读取<br> readfile(f,thetext^,textsize,bytesred,nil);<br> s:=thetext;<br> //释放内存<br> freemem(thetext);<br> //关闭文件<br> closehandle(f);<br><br> listbox1.Items.Text :=s;<br>end;<br><br><br><br><br><br><br>这样运行要死机,