Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* problem domain to decompose:
- info program that displays CPU information and RAM, disk management
- CPU - temperature, different cores maybe, */
- // all errors enabled, so do this to minimise window error warnings that I cannot control
- #pragma warning(push, 0)
- #pragma warning (disable : 4668)
- #include <windows.h>
- #pragma warning(pop)
- #include <stdbool.h>
- #include <stdio.h>
- int main(void)
- {
- // declare variables to pass into disk space function
- ULARGE_INTEGER FreeBytesToCaller;
- ULARGE_INTEGER TotalBytes;
- ULARGE_INTEGER TotalFreeBytes;
- // declare variable to hold the calculation to convert bytes to gibabytes
- ULARGE_INTEGER BytesToGB;
- BytesToGB.QuadPart = 1024 * 1024 * 1024;
- // call function to retreive disk space information
- bool DiskResult = GetDiskFreeSpaceExA(0, &FreeBytesToCaller, &TotalBytes, &TotalFreeBytes);
- // variables to hold result of conversion calculation
- ULARGE_INTEGER GBTotal;
- ULARGE_INTEGER TB;
- ULARGE_INTEGER GBTotalFreeBytes;
- // QuadPart that holds the actual 64 bit integer. Need to do this for maths operations
- // calculations
- GBTotal.QuadPart = TotalBytes.QuadPart / BytesToGB.QuadPart;
- GBTotal.QuadPart = GBTotal.QuadPart % 1000;
- TB.QuadPart = TotalBytes.QuadPart / (BytesToGB.QuadPart * 1024);
- GBTotalFreeBytes.QuadPart = TotalFreeBytes.QuadPart / BytesToGB.QuadPart;
- if (DiskResult != 0)
- {
- // print out info for D drive
- printf("Total size on disk (D:): %llu.%llu TB\n", TB.QuadPart, GBTotal.QuadPart);
- printf("Total free space (D:): %llu GB\n", GBTotalFreeBytes.QuadPart);
- printf("Heloo\n");
- }
- else
- {
- OutputDebugStringA("DiskResult failed!\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment