Ok, here's the main program:
Code:
#include "Initialization.h"
#include "resource.h"
/*
Project 0, Main
*/
//prototypes
LRESULT CALLBACK WndProc (HWND hwndMain, UINT message, WPARAM wParam, LPARAM lParam);
//global variables
static TCHAR szAppName[] = TEXT ("Project 0"); //name of window class
RECT rect; //
HWND hwndMain, hwndNew, hwndLoad, hwndOptions, hwndQuit, hwndOptionsBack; //handle to a window
HDC hdc, hdcBitmapMem; //
MSG msg; //structure for MSG
WNDCLASS wc; //structure for WNDCLASS
int cxScreen, cyScreen;
int btnHeight = 30;
int btnWidth = 110;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdline, int iCmdShow)
{
Hard_Drive ();
if (flag = 0)
{
return (0);
}
//register a window class
etc...
Right now the only thing I initialize is the Hard_Drive (hence the function call). I truncated the remainder of the program, since that works fine.
Here's the initialization program:
Code:
#include "Initialization.h"
int Hard_Drive (void)
{
bReturn = GetDiskFreeSpace
(
TEXT ("C:\\"),
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwFreeClusters,
&dwTotalClusters
);
if (bReturn)
{
/* cast it to 64 bits for calculations */
i64TotalBytes = (__int64)dwTotalClusters * dwSectorsPerCluster * dwBytesPerSector;
i64AvailableBytes = (__int64)dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
//printf ("Available = %I64u MB\n", i64AvailableBytes / (1024 * 1024));
//printf ("Total = %I64u MB\n", i64TotalBytes / (1024 * 1024));
flag = 1;
if ((i64AvailableBytes / (1024 * 1024)) < 16000)
{
MessageBox (NULL, TEXT ("ERROR! Not enough hard drive space!"), NULL, MB_ICONERROR);
flag = 0;
}
}
else
{
flag = 0;
}
return flag;
}
That's the entire initialization so far... I have it set to give me an error if the available space is less than 16 gigabytes. I have 15 gigabytes remaining on my hard drive, and this forces an error to occur so that I can test this.
Here's the header file that both the main and the initialization program include:
Code:
#define WIN32_LEAN_MEAN
#define VC_LEAN
#include <windows.h>
#include <stdio.h>
//Hard drive initialization declarations
//======================
unsigned __int64 i64TotalBytes, i64AvailableBytes;
BOOL bReturn;
DWORD dwSectorsPerCluster, dwBytesPerSector, dwFreeClusters, dwTotalClusters;
int Hard_Drive (void);
int flag;
//======================
#endif