Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem in getting free space using GetDiskFreeSpaceExA

97 views
Skip to first unread message

Karthik

unread,
Oct 4, 2005, 9:01:37 AM10/4/05
to
Hi All,

I am using the following code in order to find the free space
for the specified hard drive. I am getting some weird output by using this
API. Could someone please help me in point out the issue.

Here is my code

String ls_total_bytes, ls_free_bytes, ls_used_bytes
Double ld_total_bytes, ld_high_temp,
ld_low_temp,ld_free_bytes,ld_used_bytes
LARGE_INTEGER lli_caller, lli_total, lli_free


ZeroMemory( lli_caller, 8 )
ZeroMemory( lli_total, 8 )
ZeroMemory( lli_free, 8 )
GetDiskFreeSpaceExA(ls_drive , lli_caller, lli_total, lli_free )

ld_total_bytes = (lli_total.HighPart * 4294967295.0) +
lli_total.LowPart
ld_free_bytes = (lli_free.HighPart * 4294967295.0) +
lli_free.LowPart
ld_used_bytes = ld_total_bytes - ld_free_bytes

In the above coding I am getting ld_total_bytes = 0 eventhough I
have the value in both highpart & lowpart.


Any help will be greatly appreciated

Thanks
Karthik


Terry Dykstra

unread,
Oct 4, 2005, 10:51:15 AM10/4/05
to
What's a LARGE_INTEGER? I would imagine that you need a long.

--
Terry Dykstra (TeamSybase)
http://powerbuilder.codeXchange.sybase.com/
http://www.pb9books.com
product enhancement requests:
http://my.isug.com/cgi-bin/1/c/submit_enhancement


"Karthik" <kp...@laborfinders.com> wrote in message
news:43427ca3$1@forums-2-dub...

Karthik

unread,
Oct 4, 2005, 11:42:28 AM10/4/05
to
LARGE_INTEGER is a structure that has 2 following columns

unsignedlong highpart
unsignedlong lowpart

API Declarations are
SUBROUTINE ZeroMemory(ref structure lpVoid, ulong dwSizeofStruct) LIBRARY
"kernel32.dll" Alias for "RtlZeroMemory;ansi"
FUNCTION boolean GetDiskFreeSpaceExA( string lpDirName, REF
LARGE_INTEGER lpFreeBytesToCaller, REF LARGE_INTEGER lpTotalBytes,
REF LARGE_INTEGER lpTotalFreeBytes ) LIBRARY "kernel32.dll" alias for
"GetDiskFreeSpaceExA;ansi"


"Terry Dykstra" <tddy...@forestoil.ca> wrote in message
news:434296e3@forums-1-dub...

Brad Wery

unread,
Oct 4, 2005, 12:11:22 PM10/4/05
to
Here's what I came up with and it seems to work:


LARGE_INTEGER lli_caller, lli_total, lli_free
LongLong ll_free, ll_total

GetDiskFreeSpaceExA("C:\" , lli_caller, lli_total, lli_free )

ll_free = LongLong ( lli_free.lowpart, lli_free.highpart )
ll_total = LongLong ( lli_total.lowpart, lli_total.highpart )


Good Luck,

Brad

Karthik

unread,
Oct 4, 2005, 2:40:41 PM10/4/05
to
Thanks Brad.

I make it to work.
"Brad Wery" <bradweryatagricoreunited.com> wrote in message
news:4342a9aa@forums-1-dub...

0 new messages