mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create free_disk_space.c
This commit is contained in:
parent
57a2578aba
commit
441e316f0e
23
system/free_disk_space.c
Normal file
23
system/free_disk_space.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user