#if _MSC_VER > 1000
#pragma once
#endif
#include <windows.h>
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 <afxwin.h>
#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 );
}文章来源:https://www.toymoban.com/news/detail-813599.html
double CHardDiskManager::GetTotalNumberOfFreeGBytes(void)
{
return (double)( (signed __int64)(m_uliTotalNumberOfFreeBytes.QuadPart)/1073741824 );
}文章来源地址https://www.toymoban.com/news/detail-813599.html
到了这里,关于磁盘空间大小管理的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!