OpenNFSe

OpenNFSe (http://www.opennfse.com.br/forums/index.php)
-   Exemplos (http://www.opennfse.com.br/forums/forumdisplay.php?f=10)
-   -   Função para formatar Bytes como no explorer (http://www.opennfse.com.br/forums/showthread.php?t=1)

LuizVaz 24/10/2009 07:01

Função para formatar Bytes como no explorer
 
Função de para formatar o tamanho em bytes igual ao Explorer.
Basta adicionar a unit shlwapi para a sua unit antes.


Código:

Uses shlwapi;


//Retorna o tamanho com sufixo: bytes, KB, MB, GB
function ByteSize(Value: Int64): String;
var buf: array[0..20] of Char;
begin
  if StrFormatByteSizeW(Value, @buf, Length(buf)) = nil then
    raise EConvertError.CreateFmt('Error converting %d', [Value]);
  Result := WideCharToString(@buf);
end;

Luiz Vaz


Horários baseados na GMT -2. Agora são 10:09.

vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0