GetDiskFreeSpaceEx() oddity on Windows XP

F

Florian

Hi,

I'm using the GetDiskFreeSpaceEx() API call and I'm getting really strange
results on one machine, a Windows XP (fully patched) machine. The code looks
like this:

ULARGE_INTEGER uiNotUsed, uiTotalNumberBytes, uiTotalNumberFreeBytes;

if (GetDiskFreeSpaceEx(cDrive, &uiNotUsed, &uiTotalNumberBytes,
&uiTotalNumberFreeBytes))
{
__int64 iFree64 = uiTotalNumberFreeBytes.QuadPart / (1024 * 1024);
__int64 iTotal64 = uiTotalNumberBytes.QuadPart / (1024 * 1024);

int iFree = iFree64;
int iTotal = iTotal64;
}

So I'm basically trying to store the number of megabytes in an integer
variable. This works on all Win2k (4) and Windows Server 2003 (2) machines
and works on two XP machines. But there is one laptop (that has no other
problems) where I will always get these values for both the total and free
space:

1407374883553280 (which is 0x5000000000000)

Can anybody explain to me what the **** is going on here? The laptop has one
harddisk (60Gb) with two logical drives (35.6Gb/2.33Gb free & 18.6Gb/6.42Gb
free).

I'm at a point where I can't use the app on this computer - and I'm worried
that I'm going to find more like that ... I couldn't find any problems in
technet,kb etc. so far. If I'm doing something wrong then I'd love to know
what I am doing wrong .... Even a printf("%i64d",
uiTotalNumberFreeBytes.QuadPart) shows the odd values ...


Thanks!
 
F

Florian

I was able to track this problem down further. The application that is
calling GetDiskFreeSpaceEx() is a windows nt service written in C++. If I
take the same code and put it into a "normal" app and run it from the
command line, then the values returned are correct. However if I run it from
the service then I get the wrong values.

I read about somebody else having a similar problem with a service written
in VB - only that it was Windows Server 2003 and not XP. Sounds similar
enough to me though - in that case the values returned were way too high
also - unfortunately there was no solution in that case either (none I know
of). I wonder if there is an issue not widely known.

Thanks ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top