Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.11.21;
Скачать: 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 вся ветка

Текущий архив: 2004.11.21;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.026 c
3-1098696936
Mikhail
2004-10-25 13:35
2004.11.21
не могу удалить или переименовать столбцы в БД


3-1098520411
Black
2004-10-23 12:33
2004.11.21
Защита базы данных ACCESS


14-1099917610
1g0r
2004-11-08 15:40
2004.11.21
Ищу игру "Пижамчик"


4-1097256441
Yaral
2004-10-08 21:27
2004.11.21
События принтера


11-1082055402
Deimos
2004-04-15 22:56
2004.11.21
RichEdit