Unhandled Exceptions different in 64bit? / vs2008
I have a program that works fine in 32bit mode on vs6.
but in 2008 64bit it sometimes gets an unhandled exception crash in the following code (PostMessage line):-
Is something different in 64bit vs2008? error is: Access violation reading location
if(wnd && ::IsWindow(wnd->m_hWnd))
{
try
{
wnd->PostMessage(WM_COMMAND,MAKELONG(0x01,BN_CLICKED),(LPARAM)(wnd->GetDlgItem(0x01))->m_hWnd); // post ok to message
}
catch(...)
{
// do nothing
}
}
Re: Unhandled Exceptions different in 64bit? / vs2008
Quote:
Originally Posted by
hobnob
I have a program that works fine in 32bit mode on vs6.
After 80 posts and no code tags?
Quote:
but in 2008 64bit it sometimes gets an unhandled exception crash in the following code (PostMessage line):-
That line just assumes that wnd->GetDlgItem(0x01) returns a valid pointer.
Regardless of the OS, you should be checking all of your pointers are not NULL before you use them.
Code:
if(wnd && ::IsWindow(wnd->m_hWnd))
This does not guarantee that the wnd is a valid instance.
It could very well be that wnd is an invalid pointer value which isn't NULL, and the contents of wnd->m_hWnd just by luck happens to be a valid window handle. Then you go and use the junk pointer in the call to wnd->PostMessage.
So you have two holes in the code you're showing, and again, regardless of the OS, should be rectified.
Regards,
Paul McKenzie