How can we use the DLL in a C program.how can we use the functions in a dll in C program?

There are 2 common methods:

1. The DLL that you have should have an import library which when linked into your EXE program provides compile time information for the linker to bind the function calls to the DLL.  If you have an H file for the functions in the DLL, use the functions normally and link into the executable the import lib (.LIB file type).  Some tools will take a DLL and create the import LIB for you.

2.  Look up the function names at runtime and call the returned address using a pointer to function.  Use LoadLibrary to load a handle to the DLL and use GetProcAddress to get a pointer to the function that you can call directly.  Remember you have to use __cdecl calling convention.



All Answers

Answers by Expert:

Ask Experts


Bill A


I can answer questions about C++, programming algorithms, Windows programming in MFC (which is C++). I cannot answer questions about STL (templates) and I have no experience with Linux. I do enjoy reviewing code and critiquing it or finding problems in it. I will also gladly show better algorithms or methods if you want to take advantage of that.


I've developed a commercial embedded C compiler/assembler and IDE with debugger toolset, of which the IDE and debugger are written in C++. I work in the industry writing high tech embedded programs and Windows programs to communicate with the embedded devices.

Book: Embedded Systems Design using the Rabbit 3000 Microprocessor Authored Chapter 10 in its entirety.

BS Computer Engineering

©2016 About.com. All rights reserved.