Last active
January 24, 2022 16:04
-
-
Save OlivierLaflamme/9f515030296fbd01e8161bd0cf1a8b7b to your computer and use it in GitHub Desktop.
Check to see if user has greater than 100GB in C drive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool isDiskSpaceAvailable() | |
{ | |
// Disk size | |
// We are using GetDiskFreeSpaceExA | |
// Retrieves information about the amount of space that is available on a disk volume, | |
// which is the total amount of space, the total amount of free space, and the total | |
// amount of free space available to the user that is associated with the calling thread. | |
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexa | |
ULARGE_INTEGER iFreeBytesAvailableToCaller, iTotalNumberOfBytes, iTotalNumberOfFreeBytes; | |
if (GetDiskFreeSpaceExA("C:\\", &iFreeBytesAvailableToCaller, &iTotalNumberOfBytes, &iTotalNumberOfFreeBytes)) // Retrieve information for disk C: | |
{ | |
if (iTotalNumberOfBytes.QuadPart / 1073741824 > 100) // If total size of disk more than 100 Gb | |
{ | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment