Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Calling Functions from DLL

Status
Not open for further replies.

mesfet

Full Member level 2
Joined
Jan 4, 2002
Messages
131
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
1,111
Hi All,

I have a DLL file and the *.h file which describe the functions contained in the DLL. Can anyone tell me how to call functions in the DLL in C? I am using Visual Studio? Do I need to define something "extern ....." in my program? or I need to setup the compiler......etc. It is great if anyone has some examples.


Thanks,
MESFET+
 

If you do not have the .lib file that come with the DLL, you will be obliged to load dynamically your DLL :


here is a example :
assuming you have a DLL (in the right directory) called mylib.dll with the following function
int my_fct( int a, int b)

to load & use it (it's one way to do it...)

typedef int(*my_fct_proto)( int , int );
my_fct_proto Proc_my_fct;
HINSTANCE myDllHandle;

myDllHandle = LoadLibrary("mylib");
Proc_my_fct = (my_fct_proto) GetProcAddress(myDllHandle, "my_fct");

int result = (Proc_my_fct)( 2, 3 );



note : that msdn site has more than enough info about all MS ways of coding(/thinking...)
 

if you have the *.lib file for the dll, you simply go to linker options, add the lib file to additional dependencies, #include the *.h file in your source file, and you can call the functions
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top