#include <windows.h>
#include <stdio.h>
typedef BOOL (WINAPI *PGETDISKFREESPACEEX)(LPCSTR,
PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
BOOL MyGetDiskFreeSpaceEx(LPCSTR pszDrive)
{
PGETDISKFREESPACEEX pGetDiskFreeSpaceEx;
__int64 i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
DWORD dwSectPerClust,
dwBytesPerSect,
dwFreeClusters,
dwTotalClusters;
BOOL fResult;
pGetDiskFreeSpaceEx = (PGETDISKFREESPACEEX)GetProcAddress(
GetModuleHandle("kernel32.dll"),
"GetDiskFreeSpaceExA");
if (pGetDiskFreeSpaceEx)
{
fResult = pGetDiskFreeSpaceEx (pszDrive,
(PULARGE_INTEGER)&i64FreeBytesToCaller,
(PULARGE_INTEGER)&i64TotalBytes,
(PULARGE_INTEGER)&i64FreeBytes);
// Process GetDiskFreeSpaceEx results.
if(fResult)
{
printf("Total free bytes =%I64d\n", i64FreeBytes);
}
return fResult;
}
else
{
fResult =GetDiskFreeSpaceA(pszDrive,
&dwSectPerClust,
&dwBytesPerSect,
&dwFreeClusters,
&dwTotalClusters);
// Process GetDiskFreeSpace results.
if(fResult)
{
printf("Total free bytes =%I64d\n", dwFreeClusters*dwSectPerClust*dwBytesPerSect);
}
return fResult;
}
}
int main(int argc, char *argv[])
{
MyGetDiskFreeSpaceEx ("C:");
}
'Programming > MFC' 카테고리의 다른 글
타이틀바를 없앤다. (0) | 2007.10.24 |
---|---|
[MFC] Thread 정복 2 - 스레드 종료하기 (0) | 2007.10.10 |
API FAQ (0) | 2007.10.10 |
GetFileSize (0) | 2007.10.10 |
시스템 재부팅 코드 (0) | 2007.09.12 |