Search code examples
c++dllmfcloadlibrarycdialog

Show dialog from MFC DLL


I loaded the form but only buttons without functions

HMODULE hModule = LoadLibrary(L"Tools.dll");

if (hModule != NULL)
{
    AfxSetResourceHandle(hModule);
    CDialog dgl(MAKEINTRESOURCE(199), NULL);
    dgl.DoModal(); 
}

so how I can load a full function of form and I don't have the DLL source code


Solution

  • This is possible only if you are sure that dialog class implementation is MFC based and the class is exported from Tools.dll. You can try inspect your .dll with Dependency Walker utility.
    Please note the compiler mangles constructor name. This is what I got for the following declaration.

    class __declspec(dllexport) TestDialog : public CDialog
    {
    public:
        TestDialog()
            :CDialog(10)
        {
    
        }
    };
    

    Mangled constructor name: ??_7TestDialog@@6B@

    Probably you will be able to recreate dialog class header based on the results of your inspection. You should also make sure you have the same version of MFC both for Tools.dll and your application.