1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MainWindow of dll how to launch from client exe

Discussion in 'MFC' started by sujan.dasmahapatra, Nov 22, 2011.

  1. sujan.dasmahapatra

    sujan.dasmahapatra New Member

    Jun 11, 2009
    Likes Received:
    Trophy Points:
    Dear Friends I have two mfc application. One is a dll and the other one is a client:) exe application. From the exe application I am trying to load the dll and launch the mainwindow of the dll.
    For that in dll.....I have the view class there in view implementation file i am declaring a view pointer, like the code below
    //RevolutionProjView.cpp file
    CRevolutionProjView *view;
     view = this;
    // The I am creating an [URL=http://www.go4expert.com/articles/using-extern-c-c-function-cpp-vice-versa-t27221/]extern C[/URL] function by name runAppli like below.
    extern "C" BOOL __declspec(dllexport) runAppli(void)
      return true;
    Now I have exe applicatioln where I want to launch the mainwindow of the dll above is given below.
    void CClientRevProjDlg::OnBnClickedButton1()
        typedef VOID (*MYPROC)(void);
        HINSTANCE hinstLib;
        MYPROC ProcAdd;
        BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
        hinstLib = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj_OrthoGraphic\\debug\\RevolutionProj.dll");
     if (hinstLib != NULL)
            ProcAdd = (MYPROC) GetProcAddress(hinstLib, "runAppli");
            if (fRunTimeLinkSuccess = (ProcAdd != NULL))
            (ProcAdd) ();
            fFreeResult = FreeLibrary(hinstLib);
        if (! fRunTimeLinkSuccess)
            printf("message via alternative method\n");
    With this my application mainwindow is appearing but immediately its crashing. Can anyone tell me whats going wrong. How can I launch the mainwindow of the dll ?? Please help me. Thanks Sujan

Share This Page