Note that there are some explanatory texts on larger screens.

plurals
  1. POMFC Fail to Load Dlg from DLL
    primarykey
    data
    text
    <p>I have installed in my PC VS2008 and Windows Mobile 6 SDK.</p> <p>I have made a SmartDevice MFC application and a Regular DLL MFC, both uses shared MFC DLL.</p> <p>But when I called DoModal() of the DLL the application hangs, show a "Debug Assertion Failed" message and freeze my device.</p> <p>Can you help me?</p> <p>Codes:</p> <p>The EXE code:</p> <pre><code>typedef BOOL (CALLBACK* LPFNDLLLOAD)(); typedef BOOL (CALLBACK* LPFNDLLRUN)(HINSTANCE, HWND, LPBYTE *, LONG *); BOOL CTesteExeDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon //CModule mod; //mod.Create(L"\\Program Files\\PMA\\Teste.dll"); //mod.Run(AfxGetInstanceHandle(), GetSafeHwnd(), 0, 0); HMODULE m_hModule = AfxLoadLibrary(L"\\Program Files\\PMA\\TesteDll.dll"); LPFNDLLLOAD m_lpfnLoad= (LPFNDLLLOAD)GetProcAddress(m_hModule, _T("_Load")); LPFNDLLRUN m_lpfnRun = (LPFNDLLRUN)GetProcAddress(m_hModule, _T("_Run")); m_lpfnLoad(); m_lpfnRun(AfxGetInstanceHandle(), GetSafeHwnd(), 0, 0); return TRUE; // return TRUE unless you set the focus to a control } </code></pre> <p>The DLL Code:</p> <p>I remove default CTesteDllApp class and put this:</p> <pre><code>#include "stdafx.h" #include "TesteDll.h" #include "TesteDllDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif extern "C" BOOL PASCAL EXPORT _Load() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return TRUE; } extern "C" BOOL PASCAL EXPORT _Unload() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return TRUE; } extern "C" BOOL WINAPI EXPORT _Run(HINSTANCE hInst, HWND hwndParent, LPBYTE *buffer, LONG *size) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CTesteDllDlg d; d.DoModal(); ////-------------&gt; Error Here return FALSE; } </code></pre> <p>The DLL Dlg code:</p> <pre><code>BOOL CTesteDllDlg::OnInitDialog() { CDialog::OnInitDialog(); AfxMessageBox(L"Oi"); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } </code></pre> <p>The def File in DLL ; TesteDll.def : Declares the module parameters for the DLL.</p> <pre><code>LIBRARY "TesteDll" EXPORTS ; Explicit exports can go here _Load @1 _Unload @2 _Run @3 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload