磁盘空间大小管理

#if _MSC_VER > 1000
#pragma once
#endif

#include

class CHardDiskManager
{
public:
CHardDiskManager();
virtual ~CHardDiskManager();

bool CheckFreeSpace(LPCTSTR lpDirectoryName);

DWORD64 GetFreeBytesAvailable(void);
DWORD64 GetTotalNumberOfBytes(void);
DWORD64 GetTotalNumberOfFreeBytes(void);

double GetFreeGBytesAvailable(void);
double GetTotalNumberOfGBytes(void);
double GetTotalNumberOfFreeGBytes(void);
private:
ULARGE_INTEGER m_uliFreeBytesAvailable;
ULARGE_INTEGER m_uliTotalNumberOfBytes;
ULARGE_INTEGER m_uliTotalNumberOfFreeBytes;
};

// HardDiskManager.cpp
#include “stdafx.h”
#include
#include “HardDiskManager.h”

CHardDiskManager::CHardDiskManager()
{
m_uliFreeBytesAvailable.QuadPart = 0L;
m_uliTotalNumberOfBytes.QuadPart = 0L;
m_uliTotalNumberOfFreeBytes.QuadPart = 0L;
}

CHardDiskManager::~CHardDiskManager()
{
}
bool CHardDiskManager::CheckFreeSpace(LPCTSTR lpDirectoryName)
{
if( !GetDiskFreeSpaceEx(
lpDirectoryName,
&m_uliFreeBytesAvailable,
&m_uliTotalNumberOfBytes,
&m_uliTotalNumberOfFreeBytes) )
return false;

return true;

}
DWORD64 CHardDiskManager::GetFreeBytesAvailable(void)
{
return m_uliFreeBytesAvailable.QuadPart;
}

DWORD64 CHardDiskManager::GetTotalNumberOfBytes(void)
{
return m_uliTotalNumberOfBytes.QuadPart;
}
DWORD64 CHardDiskManager::GetTotalNumberOfFreeBytes(void)
{
return m_uliTotalNumberOfFreeBytes.QuadPart;
}

double CHardDiskManager::GetFreeGBytesAvailable(void)
{
return (double)( (signed __int64)(m_uliFreeBytesAvailable.QuadPart)/1073741824 );
}
double CHardDiskManager::GetTotalNumberOfGBytes(void)
{
return (double)( (signed __int64)(m_uliTotalNumberOfBytes.QuadPart)/1073741824 );
}

double CHardDiskManager::GetTotalNumberOfFreeGBytes(void)
{
return (double)( (signed __int64)(m_uliTotalNumberOfFreeBytes.QuadPart)/1073741824 );
}

你可能感兴趣的:(算法)