From: JRGlide on 9 May 2008 13:16 I have been struggling several weeks with this problem. I need to call an MFC dll from a non-MFC application. The MFC dll was originally a working MFC program that I conveted to a dll. The dll works fine except that it crashes when I exit. Can anyone provide me with some snippets of working code showing how you did this? An example of the calling code, the CWinApp (or at least the InitInstance) and the hook function would be great. I have read several times that this should be easy to do, so I am probably just missing a simple line somewhere. The way I created my dll is to use to App Wizard to create an MFC dll. Then I simply added my working application code to the dll skeleton code, and added a 'C' hook function to CWinApp that can be called from the outside. Today I decided to go back to basics, so I created a simple Doc/View application using the wizard. I then converted that to a dll and I had the same problem - it crashed when exiting. Any help would be greatly appreciated. In case it matters, I am using Visual C++ 6.0 and and want to statically link into the MFC library. Thank you, Jim
From: David Ching on 9 May 2008 13:59 "JRGlide" <JRGlide(a)discussions.microsoft.com> wrote in message news:2C839E5C-F0B1-40A5-9EBC-BE6890A54B7B(a)microsoft.com... >I have been struggling several weeks with this problem. I need to call an >MFC > dll from a non-MFC application. The MFC dll was originally a working MFC > program that I conveted to a dll. The dll works fine except that it > crashes > when I exit. > > Can anyone provide me with some snippets of working code showing how you > did > this? An example of the calling code, the CWinApp (or at least the > InitInstance) and the hook function would be great. I have read several > times that this should be easy to do, so I am probably just missing a > simple > line somewhere. > > The way I created my dll is to use to App Wizard to create an MFC dll. > Then > I simply added my working application code to the dll skeleton code, and > added a 'C' hook function to CWinApp that can be called from the outside. > > Today I decided to go back to basics, so I created a simple Doc/View > application using the wizard. I then converted that to a dll and I had > the > same problem - it crashed when exiting. > > Any help would be greatly appreciated. In case it matters, I am using > Visual C++ 6.0 and and want to statically link into the MFC library. > Please show the stack trace where it crashes on exit. -- David
From: JRGlide on 9 May 2008 15:23 > Please show the stack trace where it crashes on exit. Thank you for answering, David. Here is the stack trace. BTW, I noticed on another post where you said you had done this lots of times. Do you think you could include some sample code? Thank you in advance, Jim STACK TRACE CFrameWnd::OnClose() line 829 + 8 bytes CWnd::OnWndMsg(unsigned int 16, unsigned int 0, long 0, long * 0x0012f2f8) line 1825 CWnd::WindowProc(unsigned int 16, unsigned int 0, long 0) line 1585 + 30 bytes AfxCallWndProc(CWnd * 0x008b1320 {CWnd hWnd=0xdddddddd}, HWND__ * 0x00100338, unsigned int 16, unsigned int 0, long 0) line 215 + 26 bytes AfxWndProc(HWND__ * 0x00100338, unsigned int 16, unsigned int 0, long 0) line 368 USER32! 77d48709() USER32! 77d487eb() USER32! 77d4b368() USER32! 77d4b3b4() NTDLL! 7c90eae3() USER32! 77d4e010() UXTHEME! 5ad73c20() UXTHEME! 5ad8e300() UXTHEME! 5ad71ac7() UXTHEME! 5ad7367a() USER32! 77d4e02b() USER32! 77d48709() USER32! 77d487eb() USER32! 77d4c00e() USER32! 77d4e366() CWnd::DefWindowProcA(unsigned int 274, unsigned int 61536, long 13370660) line 1000 + 32 bytes CWnd::Default() line 249 CWnd::OnSysCommand(unsigned int 61536, unsigned int 61536) line 418 + 15 bytes CFrameWnd::OnSysCommand(unsigned int 61536, long 13370660) line 1046 CWnd::OnWndMsg(unsigned int 274, unsigned int 61536, long 13370660, long * 0x0012f884) line 1849 CWnd::WindowProc(unsigned int 274, unsigned int 61536, long 13370660) line 1585 + 30 bytes AfxCallWndProc(CWnd * 0x008b1320 {CWnd hWnd=0xdddddddd}, HWND__ * 0x00100338, unsigned int 274, unsigned int 61536, long 13370660) line 215 + 26 bytes AfxWndProc(HWND__ * 0x00100338, unsigned int 274, unsigned int 61536, long 13370660) line 368 USER32! 77d48709() USER32! 77d487eb() USER32! 77d4b368() USER32! 77d4b3b4() NTDLL! 7c90eae3() USER32! 77d4b7ab() UXTHEME! 5ad9881f() UXTHEME! 5ad71ac7() UXTHEME! 5ad7367a() USER32! 77d4e02b() USER32! 77d48709() USER32! 77d487eb() USER32! 77d4c00e() USER32! 77d4e366() CWnd::DefWindowProcA(unsigned int 161, unsigned int 20, long 13370660) line 1000 + 32 bytes CWnd::WindowProc(unsigned int 161, unsigned int 20, long 13370660) line 1586 + 26 bytes AfxCallWndProc(CWnd * 0x008b1320 {CWnd hWnd=0xdddddddd}, HWND__ * 0x00100338, unsigned int 161, unsigned int 20, long 13370660) line 215 + 26 bytes AfxWndProc(HWND__ * 0x00100338, unsigned int 161, unsigned int 20, long 13370660) line 368 USER32! 77d48709() USER32! 77d487eb() USER32! 77d489a5() USER32! 77d4bccc() CWinThread::PumpMessage() line 846 CWinThread::Run() line 480 + 11 bytes CWinApp::Run() line 400 ViewPointCloud() line 48 main(int 1, char * * 0x00d20e60) line 68 + 8 bytes mainCRTStartup() line 206 + 25 bytes KERNEL32! 7c816d4f()
From: Ajay Kalra on 9 May 2008 21:10 On May 9, 1:16 pm, JRGlide <JRGl...(a)discussions.microsoft.com> wrote: > I have been struggling several weeks with this problem. I need to call an MFC > dll from a non-MFC application. The MFC dll was originally a working MFC > program that I conveted to a dll. The dll works fine except that it crashes > when I exit. > > Can anyone provide me with some snippets of working code showing how you did > this? An example of the calling code, the CWinApp (or at least the > InitInstance) and the hook function would be great. I have read several > times that this should be easy to do, so I am probably just missing a simple > line somewhere. > > The way I created my dll is to use to App Wizard to create an MFC dll. Then > I simply added my working application code to the dll skeleton code, and > added a 'C' hook function to CWinApp that can be called from the outside. > > Today I decided to go back to basics, so I created a simple Doc/View > application using the wizard. I then converted that to a dll and I had the > same problem - it crashed when exiting. > > Any help would be greatly appreciated. In case it matters, I am using > Visual C++ 6.0 and and want to statically link into the MFC library. > > Thank you, > > Jim What sort of DLL is it? Regular or MFC Extension. It should be a Regular DLL and you should use AFX_MANAGE_STATE to change the state as needed. --- Ajay
From: JRGlide on 9 May 2008 21:42 > What sort of DLL is it? Regular or MFC Extension. It should be a > Regular DLL and you should use AFX_MANAGE_STATE to change the state as > needed. > > --- > Ajay > Thank you for responding Ajay. Yes, I am using a regular dll since I need to call it from a non-MFC program. From what I understand, I only need the AFX_MANAGE_STATE if I am linking to MFC dynamically. But just to be sure I have it in anyway, but it doesn't help. It crashes with or without it. Here is the code with the hook function to the application and InitInstance. I tried to strip it down as much as possible. Anybody see anything that looks fishy? Thank you. ///////////////////////////////////////////////////////////////////////////// // The one and only CViewPointCloudApp object CViewPointCloudApp theApp; extern "C" { __declspec(dllexport) void ViewPointCloud (void); void ViewPointCloud (void) { AFX_MANAGE_STATE (AfxGetStaticModuleState()); theApp.Run(); } } // extern "C" BOOL CViewPointCloudApp::InitInstance() { CWinApp::InitInstance(); AfxEnableControlContainer(); // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CViewPointCloudDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CViewPointCloudView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; }
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: communication between C# dll and C++ dll ??? Next: linking with mfc42.lib and mfc90.lib? |