Skip to content

Instantly share code, notes, and snippets.

@OlivierLaflamme
Last active January 24, 2022 16:04
Show Gist options
  • Save OlivierLaflamme/9f515030296fbd01e8161bd0cf1a8b7b to your computer and use it in GitHub Desktop.
Save OlivierLaflamme/9f515030296fbd01e8161bd0cf1a8b7b to your computer and use it in GitHub Desktop.
Check to see if user has greater than 100GB in C drive
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