如何得到正在运行中文件的大小(100分)

  • 主题发起人 主题发起人 mapleroad
  • 开始时间 开始时间
M

mapleroad

Unregistered / Unconfirmed
GUEST, unregistred user!
如何得到正在运行中文件的大小<br>thanks in advance!
 
只要知道文件名和完整的路径,都可以得到他的大小,用fileopen、filesize和fileclose等。
 
var<br>&nbsp; &nbsp;f: file of Byte;<br>&nbsp; &nbsp;size : Longint;<br>&nbsp; &nbsp;S: string;<br>&nbsp; &nbsp;y: Integer;<br>&nbsp;begin<br>&nbsp; &nbsp;if OpenDialog1.Execute then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;AssignFile(f, OpenDialog1.FileName);<br>&nbsp; &nbsp; &nbsp;Reset(f);<br>&nbsp; &nbsp; &nbsp;size := FileSize(f);<br>&nbsp; &nbsp; &nbsp;S := 'File size in bytes: ' + IntToStr(size);<br>&nbsp; &nbsp; &nbsp;y := 10;<br>&nbsp; &nbsp; &nbsp;Canvas.TextOut(5, y, S);<br>&nbsp; &nbsp; &nbsp;y := y + Canvas.TextHeight(S) + 5;<br>&nbsp; &nbsp; &nbsp;S := 'Seeking halfway into file...';<br>&nbsp; &nbsp; &nbsp;Canvas.TextOut(5, y, S);<br>&nbsp; &nbsp; &nbsp;y := y + Canvas.TextHeight(S) + 5;<br>&nbsp; &nbsp; &nbsp;Seek(f,size div 2);<br>&nbsp; &nbsp; &nbsp;S := 'Position is now ' + IntToStr(FilePos(f));<br>&nbsp; &nbsp; &nbsp;Canvas.TextOut(5, y, S);<br>&nbsp; &nbsp; &nbsp;CloseFile(f);<br>&nbsp; &nbsp;end;<br>&nbsp;end;<br>你把对话匡替换为你正在打开的文件,就好了。<br>函数你应该知道吧。exetractfilepath等等。
 
兄弟,我指的是正在运行中的可执行文件?!<br>in other words, aaa.exe 在运行时如何判断自身的大小?
 
后退
顶部