I'm getting an exception in my program (I've only included the driver in this post)..
The file looks like this:
The exception is thrown on the DialogBox() line. VC++ shows me this in the debugger.
Any help would really be appreciated as to why this is happening. Thanks.
The file looks like this:
Code:
#include <windows.h>
#include "resource.h"
#include "dlgmain.h"
#include "menu.h"
#include "installcall.h"
#include "utils.h"
//--------------------------------------------------------------
// WinMain()
//--------------------------------------------------------------
int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
LPSTR lpCmdLine, int nCmdShow )
{
FARPROC lpProcMain;
lpProcMain = MakeProcInstance( (FARPROC) Main, hInst );
//
// Note that 0 is passed as the parent to the dialog
//
// ### Exception thrown on line below ####
DialogBox( hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, (DLGPROC)lpProcMain );
FreeProcInstance( lpProcMain );
return 0;
}
//--------------------------------------------------------------
// Main() Dialog callback porcedure
//--------------------------------------------------------------
BOOL CALLBACK Main(HWND hDlg, UINT message,
WORD wParam, LONG lParam)
{
RECT dlgRt;
switch (message)
{
case WM_INITDIALOG: // message: initialize dialog box
// center the dialog box
// Get the screen coordinates into dlgRt RECT
GetWindowRect( hDlg, &dlgRt );
// Moves rect to (0, 0) so the bottom and right of structure
// will equal the size of the rect
OffsetRect( &dlgRt, -dlgRt.left, -dlgRt.top );
// The rect information combined with GetSystemMetrics() is
// used to center the dialog
MoveWindow( hDlg,((GetSystemMetrics( SM_CXSCREEN ) -
dlgRt.right ) / 2 + 4) & ~7,
(GetSystemMetrics( SM_CYSCREEN ) -
dlgRt.bottom) / 2,
dlgRt.right, dlgRt.bottom, 0 );
if(!setWorkingDir(hDlg))
{
displayError(hDlg, "ERROR: Could not set working directory.");
}
loadFileToBox("instructions\\guide.txt", hDlg, IDC_EDIT1);
initInstallMenu(hDlg); // Setup the menu for install
return TRUE;
case WM_COMMAND:
return TRUE; // message: received a command
break;
}
return FALSE; // Didn't process a message
}
The exception is thrown on the DialogBox() line. VC++ shows me this in the debugger.
Unhandled exception at 0x4f525245 in dlgmain.exe: 0xC0000005: Access violation reading location 0x4f525245.
Any help would really be appreciated as to why this is happening. Thanks.