locked
Converting Exe to Dll RRS feed

  • Question

  • Hi,

    - I created a MFC Dialog application i.e. Sample.exe and build the application. Next from the project configuration i changed the type to dll from exe and removed the main() function.After successful build i got the sample.dll generated. I dont have any exported method here.

    - Now i created one more exe, called UseDll.exe. Then i loaded the Sampledll using LoadLibrary as below.

    HINSTANCE hdll = LoadLibrary( _T("Sample.dll") );

    While running the application, i found that the load library is showing the Sample dialog.

    Can anyone please let me know how its working even i am not exporting any method from the dll to show the dialog.

    Or is it the correct way to convert the exe to dll.

    Thanks 

    Lokanath Nayak.

    Tuesday, February 3, 2015 2:06 PM

Answers

  • Hi Igor,

    Actually my requirement is, i need to create a MFC dialog in a dll and need to expose some method like ShowMyDialog as below:

    extern __declspec(dllexport) void ShowMyDialog()
    {

    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    SampleDlg dlg;

    dlg.DoModal();

    }

    In my exe before calling ShowMyDialog, the dialog is getting displayed at the time of loadlibrary called.

    So can you give me an idea like, hhow to create a MFC dialog in a dll and expose to exe.

    Thanks

    • Marked as answer by Shu 2017 Tuesday, February 17, 2015 3:00 AM
    Wednesday, February 4, 2015 4:30 AM

All replies

  • On 2/3/2015 9:06 AM, LokanathNayak wrote:

    While running the application, i found that the load library is showing the Sample dialog.

    You are likely opening the dialog in InitApplication, which is now being called from DllMain (which, in turn, is called by the OS when the DLL is loaded).


    Igor Tandetnik
    Tuesday, February 3, 2015 2:14 PM
  • Hi Igor,

    Actually my requirement is, i need to create a MFC dialog in a dll and need to expose some method like ShowMyDialog as below:

    extern __declspec(dllexport) void ShowMyDialog()
    {

    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    SampleDlg dlg;

    dlg.DoModal();

    }

    In my exe before calling ShowMyDialog, the dialog is getting displayed at the time of loadlibrary called.

    So can you give me an idea like, hhow to create a MFC dialog in a dll and expose to exe.

    Thanks

    • Marked as answer by Shu 2017 Tuesday, February 17, 2015 3:00 AM
    Wednesday, February 4, 2015 4:30 AM
  • On 2/3/2015 11:30 PM, LokanathNayak wrote:

    In my exe before calling ShowMyDialog, the dialog is getting displayed at the time of loadlibrary called.

    I believe I've explained why.

    So can you give me an idea like, hhow to create a MFC dialog in a dll and expose to exe.

    Exactly the way you've shown.


    Igor Tandetnik
    Wednesday, February 4, 2015 6:37 PM