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.
vgiridharAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.