Article View: borland.public.cppbuilder.nativeapi
Article #9946Re: GetDiskFreeSpaceEx question
From: Remy Lebeau (TeamB)
Date: Tue, 01 Jun 2004 01:53
Date: Tue, 01 Jun 2004 01:53
45 lines
2310 bytes
2310 bytes
"Martin C" <martincplus@hotmail.com> wrote in message
news:40bbd229@newsgroups.borland.com...
> I am using the code below to retrieve the free diskspace
> of my hard drive, but I really don't know how to format
> the output to something like for example 55.57 GB.
I prefer something like the following approach myself:
#define KILOBYTE (1024*1)
#define MEGABYTE (1024*KILOBYTE)
#define GIGABYTE (1024*MEGABYTE)
#define TERABYTE (1024*GIGABYTE)
AnsiString __fastcall FormatSize(unsigned __int64 Size)
{
if( Size < KILOBYTE )
return AnsiString(Size) + " B";
else if( Size < MEGABYTE )
return FormatFloat("###0.00' KB'", Size / KILOBYTE);
else if( Size < GIGABYTE )
return FormatFloat("###0.00' MB'", Size / MEGABYTE);
else if( Size < TERABYTE )
return FormatFloat("###0.00' GB'", Size / GIGABYTE);
else
return FormatFloat("###0.00' TB'", Size / TERABYTE);
}
Then it can be called like this:
ULARGE_INTEGER fbatc = {0};
if( ::GetDiskFreeSpaceEx(Path.c_str(), &fbatc, NULL, NULL) )
ShowMessage(FormatSize(fbatc.QuadPart));
Or alternatively:
ShowMessage(DiskFree('C'));
Gambit
Technical Details
Message-ID:
<40bbe2b9@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-05!sn-xit-09!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40bbd229@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,782d9cc15321c56a X-Google-Attributes: gid10cc67,public From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40bbd229@newsgroups.borland.com> Subject: Re: GetDiskFreeSpaceEx question Date: Mon, 31 May 2004 18:53:51 -0700 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 67.22.135.163 Message-ID: <40bbe2b9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1086055097 67.22.135.163 (31 May 2004 18:58:17 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-05!sn-xit-09!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail