tanmh
asked on
Hard disk space
hi,
please advise if there's any Win32 API which allows the programmer to check the hard disk space utilised/free in the codes.
thanks,
andrea
please advise if there's any Win32 API which allows the programmer to check the hard disk space utilised/free in the codes.
thanks,
andrea
GetDiskFreeSpaceEx
ASKER
hi,
can u pls provide an example of how to call this func to get
the free disk space?
thanks.
can u pls provide an example of how to call this func to get
the free disk space?
thanks.
ASKER
although the API is correct but after asking for an
example for so long, there was no answer.
other experts, would appreciate it if you can help. Basically, I don't know how to pass the parameters for the API, what's PULARGE_INTEGER?
BOOL GetDiskFreeSpaceEx(
LPCTSTR lpDirectoryName,
PULARGE_INTEGER lpFreeBytesAvailableToCall er,
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes );
example for so long, there was no answer.
other experts, would appreciate it if you can help. Basically, I don't know how to pass the parameters for the API, what's PULARGE_INTEGER?
BOOL GetDiskFreeSpaceEx(
LPCTSTR lpDirectoryName,
PULARGE_INTEGER lpFreeBytesAvailableToCall
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes );
That is example of GetDiskFreeSpace:
DWORD lpSectorsPerCluster; // address of sectors per cluster
DWORD lpBytesPerSector; // address of bytes per sector
DWORD lpNumberOfFreeClusters; // address of number of free clusters
DWORD lpTotalNumberOfClusters; // address of total number of clusters
GetDiskFreeSpace("C:\\",
&lpSectorsPerCluster, // address of sectors per cluster
&lpBytesPerSector, // address of bytes per sector
&lpNumberOfFreeClusters, // address of number of free clusters
&lpTotalNumberOfClusters // address of total number of clusters
);
DWORD lFree = lpNumberOfFreeClusters * lpSectorsPerCluster *
lpBytesPerSector;
Regrds, Alex
DWORD lpSectorsPerCluster; // address of sectors per cluster
DWORD lpBytesPerSector; // address of bytes per sector
DWORD lpNumberOfFreeClusters; // address of number of free clusters
DWORD lpTotalNumberOfClusters; // address of total number of clusters
GetDiskFreeSpace("C:\\",
&lpSectorsPerCluster, // address of sectors per cluster
&lpBytesPerSector, // address of bytes per sector
&lpNumberOfFreeClusters, // address of number of free clusters
&lpTotalNumberOfClusters // address of total number of clusters
);
DWORD lFree = lpNumberOfFreeClusters * lpSectorsPerCluster *
lpBytesPerSector;
Regrds, Alex
ASKER
hi Alex,
thanks for your example.
Do u have the sample for GetDiskFreeSpaceEx instead?
or do I have to use GetDiskFreeSpace and then calculate the free disk space myself?
thanks,
Andrea
thanks for your example.
Do u have the sample for GetDiskFreeSpaceEx instead?
or do I have to use GetDiskFreeSpace and then calculate the free disk space myself?
thanks,
Andrea
ASKER
hi Alex,
I've tried out your sample code and I got the following error:
C:\ESPdev\bin\trydatetime\ main.cpp(1 33) : error C2664: 'GetDiskFreeSpaceW' : cannot convert parameter 1 from 'char [4]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Please advise.
Thanks, Andrea
I've tried out your sample code and I got the following error:
C:\ESPdev\bin\trydatetime\
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Please advise.
Thanks, Andrea
ASKER
again after so long, no response.
would appreciate if any expert can followup and provide me with a solution.
thanks,
andrea
would appreciate if any expert can followup and provide me with a solution.
thanks,
andrea
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi Alex,
Thanks for your help.
I've tried out on my VC++ v6.0 compiler.
For the 1st variant
-------------------
error C2664: 'GetDiskFreeSpaceW' : cannot convert parameter 1 from 'char [4]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
For the 2nd variant
-------------------
the compiler complained that _dos_getdiskfree(3,&d) is undeclared identifier even though i included <dos.h>
Just to check with you, for variant 1, did u set your compiler options?
Regards,
Andrea
Thanks for your help.
I've tried out on my VC++ v6.0 compiler.
For the 1st variant
-------------------
error C2664: 'GetDiskFreeSpaceW' : cannot convert parameter 1 from 'char [4]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
For the 2nd variant
-------------------
the compiler complained that _dos_getdiskfree(3,&d) is undeclared identifier even though i included <dos.h>
Just to check with you, for variant 1, did u set your compiler options?
Regards,
Andrea
ASKER
I've solved my problem already.
thanks.
thanks.