Visual C++ program compiles, but won't run

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2004
Posts: 5
Reputation: Reagan is an unknown quantity at this point 
Solved Threads: 0
Reagan Reagan is offline Offline
Newbie Poster

Visual C++ program compiles, but won't run

 
0
  #1
Nov 28th, 2004
I am working on a time card program in Visual C++ (FYI: I am VERY new to this, so, please, be gentle with me) It compiles with 0 errors and 0 warnings, but when it executes I get an error message that the program needs to close. When I tried to go into Debug, it gave me "Unhandled exception in MFCTimeCard.exe:0XC0000005: Access Violation" I click on OK and it goes to this piece of code in the AfxWinMain()

if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
nReturnCode = pThread->Run();

Please let me know if anyone needs more info. BTW: I did not touch this particular bit when working. I did however add the InitInstance() in a source file.
THANKS!!!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Visual C++ program compiles, but won't run

 
0
  #2
Nov 28th, 2004
The real error will be in the InitInstance() method.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 5
Reputation: Reagan is an unknown quantity at this point 
Solved Threads: 0
Reagan Reagan is offline Offline
Newbie Poster

Re: Visual C++ program compiles, but won't run

 
0
  #3
Nov 28th, 2004
That is kinda what I figured, but I've looked it over a dozen times Here is my code:

BOOL CTimeCardApp::InitInstance() {
CTimeCard time;
time.DoModal();
return FALSE;
}
Thanks!
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 13
Reputation: glSuccinct is an unknown quantity at this point 
Solved Threads: 1
glSuccinct's Avatar
glSuccinct glSuccinct is offline Offline
Newbie Poster

Re: Visual C++ program compiles, but won't run

 
0
  #4
Nov 29th, 2004
Doesn't returning false signify failure? I dunno, I'm not an MFC guy. If that's not the problem, then time is crashing on init.
-don't listen to me-
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Visual C++ program compiles, but won't run

 
0
  #5
Nov 30th, 2004
I think you're onto something.
Where is the CTimeCard initialised?
What is it anyway? If it's a reference to something else you're calling a method on an uninitialised object which will indeed cause an access violation.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 5
Reputation: Reagan is an unknown quantity at this point 
Solved Threads: 0
Reagan Reagan is offline Offline
Newbie Poster

Re: Visual C++ program compiles, but won't run

 
0
  #6
Dec 4th, 2004
Got it! I forgot to put in the a line to instantiate the application object. Thanks for your help!!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC