Hi All,
I am trying to call third party dll from C program. This third party dll is written in C. I am using microsoft visual studio 2005. Could anyone please give me steps to add dll tot he project and to call from C program? I am new to this field. Please guide me on this. Your help is greatly appreciated.

Thank you
Namratha

Start by loading the DLL with the LoadLibrary function. Then if the name you want is in the DLL's export table, you can call GetProcAddress to get a handle to it. Here is an example program that does everything.

Hi Tom Gunn,
Thank you for your respnse. First, I created my own dll in C. Next, I referred to the link which was provided by you and wrote a C pgm to call the dll. As mentioned by you I used loadlibrary(). Everything is working fine.

Now I want to call the thrd party dll written in C in same way. I have just a dll but do not have method name. How can I find the method name from dll? Do I need to have header file to call the dll? What info I need to ask from the third party dll provider? Please clarify on this.

Thank you,
Namratha

Now I want to call the thrd party dll written in C in same way. I have just a dll but do not have method name. How can I find the method name from dll? Do I need to have header file to call the dll? What info I need to ask from the third party dll provider? Please clarify on this.

You need to know the method name however the DLL is accessed.

If the provider only gives you a DLL, you can look into the file and find out what names are in the export table, or you can ask the provider what names are exported and how to use them. The second way is easier if you do not know anything about the Portable Executable file format. ;) The provider should at least give you documentation along with the DLL.

To make using a DLL easier, providers can package it with a .lib and .h file. Using the DLL with those two is just like using a static library. You link to the .lib file, include the .h file, and put the DLL in the output directory. The .h file will tell you what names are exported.

Thank you for the information. I will contact the dll provider for the dll documentation.

Thank you,
Namratha

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.