|
-
Jan 17th, 2002, 10:01 AM
#1
Thread Starter
Hyperactive Member
GetDiskFreeSpace
Can someone help me out with the GetDiskFreeSpace API?
Here is what i have and i'm getting values that don't seem correct.
Code:
unsigned long *lpSectorsPerCluster;
unsigned long *lpBytesPerSector;
unsigned long *lpNumberOfFreeClusters;
unsigned long *lpTotalNumberOfClusters;
GetDiskFreeSpace("C:", lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters);
cout << ((*lpTotalNumberOfClusters / 100) * (*lpSectorsPerCluster / 100) * (*lpBytesPerSector / 100))<< " Bytes Total" << endl;
cout << ((*lpNumberOfFreeClusters / 100) * (*lpSectorsPerCluster / 100) * (*lpBytesPerSector / 100)) << " Bytes Free" << endl;
thx in advance for any help
Bababooey
Tatatoothy
Mamamonkey
-
Jan 17th, 2002, 10:17 AM
#2
Monday Morning Lunatic
Re: GetDiskFreeSpace
Originally posted by noble
Can someone help me out with the GetDiskFreeSpace API?
Here is what i have and i'm getting values that don't seem correct.
Code:
unsigned long lpSectorsPerCluster;
unsigned long lpBytesPerSector;
unsigned long lpNumberOfFreeClusters;
unsigned long lpTotalNumberOfClusters;
GetDiskFreeSpace("C:", &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters);
cout << ((*lpTotalNumberOfClusters / 100) * (*lpSectorsPerCluster / 100) * (*lpBytesPerSector / 100))<< " Bytes Total" << endl;
cout << ((*lpNumberOfFreeClusters / 100) * (*lpSectorsPerCluster / 100) * (*lpBytesPerSector / 100)) << " Bytes Free" << endl;
The idea is that you pass a pointer to your variables, not pass the VALUE from a pointer variable you have...see my subtle changes in the variable declaration...
Argh gotta go...change the printing to avoid the dereference...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 17th, 2002, 10:28 AM
#3
Thread Starter
Hyperactive Member
still seem off by a little.....
Code:
unsigned long lpSectorsPerCluster;
unsigned long lpBytesPerSector;
unsigned long lpNumberOfFreeClusters;
unsigned long lpTotalNumberOfClusters;
GetDiskFreeSpace(szDriveLetter, &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters);
cout << ((lpTotalNumberOfClusters / 100) * (lpSectorsPerCluster / 100) * (lpBytesPerSector / 100)) << " Bytes Total" << endl;
cout << ((lpNumberOfFreeClusters / 100) * (lpSectorsPerCluster / 100) * (lpBytesPerSector / 100)) << " Bytes Free" << endl;
Bababooey
Tatatoothy
Mamamonkey
-
Jan 17th, 2002, 10:50 AM
#4
GetDiskFreeSpaceEx will be simpler to use. It was designed to replace GetDiskFreeSpace.
But if you want to use GetDiskFreeSpace, why do you divide all numbers by 100?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 17th, 2002, 10:58 AM
#5
Thread Starter
Hyperactive Member
oops, i copied some code from a previous project and forgot
to take out the dividing by 100. Still doesn't give me a correct
reading on the free space....
I'm not using GetDiskFreeSpaceEx because I need to know the
sectors and such.
Thanks again
Bababooey
Tatatoothy
Mamamonkey
-
Jan 17th, 2002, 11:51 AM
#6
Monday Morning Lunatic
Noble, I just said it was off - I'd written the core part of the reply before I got dragged off to do my presentation (on a course at the moment).
If you didn't notice the fact that I said you needed to follow the changes in the variables through to remove the dereferencing 
Anyway, have you tried looking up GetDiskSpaceFree on MSDN?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 17th, 2002, 01:11 PM
#7
Thread Starter
Hyperactive Member
thx parksie for your help, i realized what I did wrong before and
fixed it
Bababooey
Tatatoothy
Mamamonkey
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|