Вниз
Скачать: 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.026 c
3-1098451639
MORA
2004-10-22 17:27
2004.11.21
Handling Exceptions


1-1099458142
Progh
2004-11-03 08:02
2004.11.21
HexToDec


4-1096610271
KSergey
2004-10-01 09:57
2004.11.21
Позиция курсора в Edit


14-1099663127
Alibaba
2004-11-05 16:58
2004.11.21
Timer в Excel


8-1092503031
Batoon
2004-08-14 21:03
2004.11.21
Помогите определиться




   Наверх