function boyutal(iFile: integer): string;
type
TFileSizeEx = function(dw: integer; pszBuf: PChar; cchBuf: integer): PChar; stdcall;
var
shlwapi_handle: THandle;
iFile_FileSize: integer;
Calculate_Size: TFileSizeEx;
lpSize: array [0..50] of char;
begin
if iFile > 0 then
begin
iFile_FileSize := GetFileSize(iFile, nil);
shlwapi_handle := LoadLibrary('shlwapi.dll');
if shlwapi_handle = 0 then
Result:=InttoStr(iFile_FileSize)+' bytes'
else
begin
@Calculate_Size := GetProcAddress(shlwapi_handle, 'StrFormatByteSizeA');
if @Calculate_Size = nil then
Result := InttoStr(iFile_FileSize) + ' bytes'
else
begin
Calculate_Size(iFile_FileSize, lpSize, 50);
Result := lpSize;
end;
end;
end
else
Result := 'File Not Found';
FreeLibrary(shlwapi_handle);
end;
//örnek
procedure TForm1.Button1Click(Sender: TObject);
var
iOpenFile: integer;
begin
iOpenFile := FileOpen('c:\windows\system.dat', fmShareCompat or fmShareDenyNone);
ShowMessage(boyutal(iOpenFile));
//label1.caption:=boyutal(iOpenFile);
FileClose(iOpenFile);
end;