From 441e316f0e002b31b450367e7f68844c11a47fb9 Mon Sep 17 00:00:00 2001 From: janbodnar Date: Sun, 31 Jan 2016 13:57:48 +0100 Subject: [PATCH] Create free_disk_space.c --- system/free_disk_space.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 system/free_disk_space.c diff --git a/system/free_disk_space.c b/system/free_disk_space.c new file mode 100644 index 0000000..bd0f5e1 --- /dev/null +++ b/system/free_disk_space.c @@ -0,0 +1,23 @@ +#include +#include + +int wmain(void) { + + unsigned __int64 FreeBytesToCaller, + TotalBytes, + FreeBytes; + + int r = GetDiskFreeSpaceExW(L"C:\\", (PULARGE_INTEGER) &FreeBytesToCaller, + (PULARGE_INTEGER) &TotalBytes, (PULARGE_INTEGER) &FreeBytes); + + if (r == 0) { + wprintf(L"Failed to get free disk space %ld", GetLastError()); + return 1; + } + + wprintf(L"Available space to caller: %I64u MB\n", FreeBytesToCaller / (1024*1024)); + wprintf(L"Total space: %I64u MB\n", TotalBytes / (1024*1024)); + wprintf(L"Free space on drive: %I64u MB\n", FreeBytes / (1024*1024)); + + return 0; +}