Calling Export function in Exe from MFC Function

Discussion in 'MFC' started by naveen1anand, Nov 11, 2006.

  1. naveen1anand

    naveen1anand New Member

    Joined:
    Aug 17, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello All,

    From Exe function, I am able to call MFC function by loading dll. Now, I need to call a exe function, from dll. For that, I am using following code:

    In Dll file,
    Code:
    EXPORT void DllFunc(void)
    	{
    		
    	FnPtrT FnPtr = (FnPtrT)GetProcAddress(GetModuleHandle(NULL), "ExeFunc");
    	DWORD dw = GetLastError();
    	if(FnPtr)
    		(*FnPtr)("Messge From The DLL");
    	else
    		MessageBox(NULL,"Not work :(","From DLL",MB_OK);
    	}
    
    I am getting handle to the exe file....but GetProcAddress is failing and returning NULL.

    In Exe function, i have declared Exefunc as:
    Code:
    extern "C"
    {
    	EXPORT void ExeFunc(char * lpszMessage)
    	{
    		MessageBox(NULL,lpszMessage,"From ExeFunc",MB_OK);
    	}
    }
    Any information regarding this will help.

    Regards,
    Naveen Anand
     
    Last edited by a moderator: Nov 13, 2006

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice