Link to home
Start Free TrialLog in
Avatar of keithcsl
keithcsl

asked on

DLL declaration...

Hi all

I have a fuction in a DLL which I would like to use in my VC++ 6 application. Can someone tell me how I can declare the fucntion in order to use it?

Eg:
Myfunc (a: PChar; b: Boolean) returns an interger.

Regards
Keith
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keithcsl
keithcsl

ASKER

nietod

Yes, it was written in Pascal. The more complete declaration is:

function MyFunc (a: PChar; b: Boolean; c: PChar; d: PChar): integer; stdcall;

I have tried your declaration and got the following errors:

-warning C4518: '__declspec(dllimport ) ' : storage-class or type specifier(s) unexpected here; ignored

-warning C4502: 'linkage specification' requires use of keyword 'extern' and must precede all other specifiers

Linking...
-error LNK2001: unresolved external symbol _WinIVR_Dial
-fatal error LNK1120: 1 unresolved externals

One critical question. Don't I need to specify the DLL somewhere? eg the name of the DLL is MyDLL.dll.

Keith
Opps. Sorry, the line

error LNK2001: unresolved external symbol _WinIVR_Dial

was meant to be:

error LNK2001: unresolved external symbol _MyFunc

I was playing with several DLLs and copied the wrong thing.

Keith
last question first (its the easiest)

>> Don't I need to specify the DLL somewhere?
Sort of, you need to specify the DLL's export library.  That is the .lib file produced when the DLL was created, not the DLL itself.

As to the other errors, they don't make sense.  Can you post the code you used including a few lines before and after this function's declaration.   (something nearby might be causing the problem.)
nietod

thanks for the answer. my other problem was the linking of the DLL. i am now using explicit linking and it all works.

keith