Вниз
Скачать: CL | DM;

Как вычислить размер экзешника по информации из его заголовка   Найти похожие ветки 

 
Оля ©   (2004-11-10 17:03) [0]

Есть процедура на паскале:

procedure ResetFile(var file_handle:bytefile;file_name:string);
begin
{$I-}
   AssignFile(file_handle,file_name);
   Reset(file_handle);
   if IOResult<>0 then ShowMessage("Файл "+file_name+" не найден!");
{$I+}
end;

procedure GetFileSizeByHeader(file_name:string; var file_size: longint);
{вычислить размер экзешника по информации из его заголовка}
var
file_handle:Bytefile;
byte2, byte3, byte4, byte5: byte;
pages, remainder: longint;
begin
ResetFile(file_handle, file_name);
Seek(file_handle,2);
Read(file_handle,byte2);
Read(file_handle,byte3);
Read(file_handle,byte4);
Read(file_handle,byte5);
Closefile(file_handle);
pages:=byte5;
pages:=pages*$100;
pages:=pages+byte4;
dec(pages);
remainder:=byte3;
remainder:=remainder*$100;
remainder:=remainder+byte2;
file_size:=pages*$200+remainder;
end;

Как написать ее аналог на delphi?


 
Digitman ©   (2004-11-10 17:11) [1]

на кой шут ебе заголовок-то ?

открой файл (без разницы, "экзешник" он или не "экзешник") и вызови ф-цию FileSize(), передав ей факт.параметром переменную файлового типа

читаем стандартную Справку сюда :

Returns the size of a file in bytes or the number of records in a record file.

Unit

System

Category

I/O routines

function FileSize(var F): Integer;

Description

Call FileSize to determine the size of the file specified by the file variable F. To use FileSize, the file must be open. If the file is empty, FileSize(F) returns 0.

Note: FileSize can"t be used on a text file.


 
Digitman ©   (2004-11-10 17:13) [2]

приношу извинения за очепятку - потерю литеры, дабы не давать повод для пошлых острот.


 
begin...end ©   (2004-11-10 17:18) [3]

Или использовать функцию FileSizeByName (модуль idGlobal, кажется). Правда, не помню, в каких версиях Delphi она есть.


 
Sun bittern ©   (2004-11-10 17:26) [4]

>>   if IOResult<>0 then ShowMessage("Файл "+file_name+" не найден!

Ни сие факт, что файл не существует


 
begin...end ©   (2004-11-10 17:30) [5]

Оля ©   (10.11.04 17:03)

> Есть процедура на паскале:


> AssignFile(file_handle,file_name);

И не обманывай, Оля. Процедуры AssignFile в Паскале не было.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.028 c
8-1092520128
parovoZZ
2004-08-15 01:48
2004.11.21
Блокировка поверхности


1-1099755398
RSFD
2004-11-06 18:36
2004.11.21
нумерация строк


1-1099556874
LEXX_55
2004-11-04 11:27
2004.11.21
"Памогите, кто знаете". Почему ответ не верный?


14-1099252959
Bend
2004-10-31 23:02
2004.11.21
RichEdit &amp; гиперссылки


9-1089867035
Evgeniy_K
2004-07-15 08:50
2004.11.21
Окно




   Наверх