StrFormatByteSize64: how to use it?
- From: Matteo Riso <zginfo@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 18 Jun 2005 13:08:35 GMT
Hello.
I need to format a string in order to show the size of a file sized 10 GB. The string should be formatted in Explorer way, so it should show "10,0 GB". I used StrFormatByteSize (within shlwapi.dll) and this function has always worked fine, but if you need to format an Int64 value (a file sized over 2 GB), the function stops and it doesn't convert the value.
I discovered that I must use StrFormatByteSize64 and I implemented in the following way:
unit MyUnit;
.....
{$EXTERNALSYM StrFormatByteSize64}
function StrFormatByteSize64(
qdw: int64;
pszBuf: PCHAR;
uiBufSize: UINT
):PCHAR; stdcall;export;
{$EXTERNALSYM StrFormatByteSize64A}
function StrFormatByteSize64A(
qdw: int64;
pszBuf: PAnsiChar;
uiBufSize: UINT
):PAnsiChar; stdcall;export;
{$EXTERNALSYM StrFormatByteSize64W}
function StrFormatByteSize64W(
qdw: int64;
pszBuf: PWideChar;
uiBufSize: UINT
):PWideChar; stdcall;export;function StrFormatByteSize64; external 'shlwapi.dll' name 'StrFormatByteSize64A';
function StrFormatByteSize64A; external 'shlwapi.dll' name 'StrFormatByteSize64A';
function StrFormatByteSize64W; external 'shlwapi.dll' name 'StrFormatByteSize64W';
....
procedure TForm1.DimFile(Siz: Int64): string; var filesize: PAnsiChar; begin StrFormatByteSize64(Siz, FileSize,255); .... end;
When I execute this program StrFormatByteSize64 converts the value to string, but it raises also an "Access Violation" error.
Please, could you explain me where am I wrong? I am using D7 and Windows XP SP2
Thank you very much :D
-- Remove _SPAM_NO_THANKS_ to reply to my email address.
Matteo Riso http://www.zipgenius.it Happy ZipGenius User #1 .
- Follow-Ups:
- Re: StrFormatByteSize64: how to use it?
- From: Nicholas Sherlock
- Re: StrFormatByteSize64: how to use it?
- Prev by Date: Re: dynamic menu problem
- Next by Date: Re: StrFormatByteSize64: how to use it?
- Previous by thread: mxProtector
- Next by thread: Re: StrFormatByteSize64: how to use it?
- Index(es):