PC Review


Reply
Thread Tools Rate Thread

GetDiskFreeSpaceEx() oddity on Windows XP

 
 
Florian
Guest
Posts: n/a
 
      6th Apr 2004
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!



 
Reply With Quote
 
 
 
 
Florian
Guest
Posts: n/a
 
      6th Apr 2004
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 ....

"Florian" <(E-Mail Removed)> wrote in message
news:3wocc.16494$(E-Mail Removed)...
> 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!
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have a problem with the GetDiskFreeSpaceEx amiga500@gmail.com Microsoft Dot NET Compact Framework 3 20th Sep 2007 03:21 PM
pinvoke GetDiskFreeSpaceEx with UNC Rogas69 Microsoft Dot NET Framework 2 28th Mar 2006 07:51 PM
GetDiskFreeSpaceEx() Ed Microsoft C# .NET 1 7th Aug 2005 02:10 PM
GetDiskFreeSpaceEx called from a service doesn't work Florian Microsoft Windows 2000 File System 0 6th Apr 2004 11:09 PM
GetDiskFreeSpaceEx API call =?Utf-8?B?UGlua2VzaA==?= Microsoft Dot NET Compact Framework 2 1st Mar 2004 06:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:56 PM.