Software Archive
Read-only legacy content
17061 Discussions

calling a function in a dll

Intel_C_Intel
Employee
398 Views
hi,

i want to call a function from a third part dll in my program.i have tried using intefaces but always end up getting a link error.Loadlibrary and getprocaddress both return success values,however the link error persists.Please let me know if there is a different way of calling the function.
--rs
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
398 Views
If you use LoadLibrary/GetProcAddress, you have to specify a Cray pointer to the dll function:
 
INTERFACE 
   SUBROUTINE DllFoo(... 
END INTERFACE 
POINTER(p_DllFoo, DllFoo) 
... 
p_DllFoo = GetProcAddress(... 


...wait, wait, what do you mean a link error? How can you get link error when calls succeed at run-time? If you mean a run-time error (Access Violation or something), it's probably mismatch in calling convention/arguments. You also have to put appropriate !DEC$ATTRIBUTES STDCALL/C for function name and appropriate !DEC$ATTRIBUTES REFERENCE for arguments if necessary into INTERFACE block.

Jugoslav
0 Kudos
Reply