CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2007
    Location
    Bangalore,India
    Posts
    164

    Smile dll loading itself launching the application

    Dear Friends
    I am loading a dll from another exe mfc application. for that i have exposed one api 'runAppli' in the dll as extern "C". Then I am loading the dll using LoadLibrary. By loading the dll itself the dll application is launched. I am surprised. I should call the api 'runAppli' and then the application should launch but its not happening. How come it is happening please give some suggestions.

    Code:
    // in the all
    extern "C" BOOL __declspec(dllexport) runAppli(CString filename)
    {
        AFX_MANAGE_STATE(AfxGetStaticModuleState());
    	if(filename.IsEmpty())
    	return false;
    	view->ShowWindow(SW_SHOW);
    	view->loadProfile(filename);
    	view->domainSetUpForProfile();
    	view->drawLines();
    	view->drawArcs();
    	view->drawProfile();
        return true;
    }
    
    //in the client exe application
    
    void CClientRevolutionProjDlg::OnBnClickedButton1()
    {
    HINSTANCE hinstLib;
    hinstLib = LoadLibrary(L"C:\\Users\\sujan.dasmahapatra\\Documents\\Projects\\Bhagavan_SurfaceRevolution\\RevolutionProj\\debug\\RevolutionProj.dll");
    }
    By simply loading the dll the dll application is launching.. why ??? Thanks Sujan
    Last edited by Marc G; January 13th, 2012 at 02:57 AM. Reason: Fixed code tags

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: dll loading itself launching the application

    By simply loading the dll the dll application is launching.. why ???
    If your dll is MFC regular dll, the behavior is by design. MFC framework launches application class' InitInstance when global theApp instance is constructed. This happens exactly at dll load time.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured