Re: Unhandled Exceptions different in 64bit? / vs2008
Originally Posted by hobnob
I have a program that works fine in 32bit mode on vs6.
After 80 posts and no code tags?
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.
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.