• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

calling a win32 dll from ATL Component

hi,
  i had the requirement that i need to call a exported funtions from win32/MFC dlls from ATL Component. how to do this can any one please suggest.
0
vgiridhar
Asked:
vgiridhar
3 Solutions
 
AlexFMCommented:
Non-MFC Dll can be called from ATL component by the same way like from any project. All .lib file to the priject, include h-file and call functions and classes.
MFC extension Dll can be called only from project with MFC support.
Regulary MFC Dll can be called from any project, even if it doesn't has MFC support. Regulary MFC Dll exposes standard interface - exported classes or functions, and can be used as any other Dll.
0
 
venkaiahCommented:
There are two ways..

1. is as AlexcFM said above.
2.using LoadLibrary and GetProcAddress API's


I hope this will help you.

Thanks,
Venkaiah.
0
 
Raj_KauCommented:
the code that help you

typedef DWORD ( *hh1)(LPSTR strPass1, LPSTR strPass2);
hh1 function_from_dll;

CString strRet;
CString strPass1;
CString strPass2

     HINSTANCE hLib;
     hLib = LoadLibrary(("Example.dll"));
     if(hLib!=NULL)
     {
          function_from_dll= (hh1)GetProcAddress(hLib, ("getURL"));
          strRet= function_from_dll(strPass1,strPass2);
     }
     FreeLibrary(hLib);






Raj
0
 
Deepu AbrahamR & D Engineering ManagerCommented:
To assist what AlexFM's point 1.

To include the .lib file into the project you could add this line of code into one of your .h/.cpp file:
#pragma comment(lib, "your_dll's_lib.lib")

Or

You could add it through IDE like MSVC++, which will have some UI's dialog boxes to add this in to the project. (I think it is in Project Settings)

I hope that now you are allready and equipped with all the possible ways of calling the .dlls from other application.

Best Regards,
DeepuAbrahamK
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now