0

I have a simple DLL written with VC6 with one function:

__declspec(dllexport) int myfunc(long a, unsigned char *b, unsigned char *c, unsigned char *d, unsigned char *e)

And im calling it from vb6 using:

Declare Function myfunc Lib "mylib.dll" (ByVal a As Long, ByVal b As String, ByVal c As String, ByVal d As String, ByVal e As String) As Long

....

dim a as long
dim b as string
dim c as string
dim d as string
dim e as string
dim r as long

r=myfunc(a,b,c,d,e)

Im getting "bad dll calling convention" error but I cant figure out why. Any ideas?

2 Answers 2

3

Generally speaking, 'bad DLL...' means what it says. VB6 requires the _stdcall convention (like the Win API) for any external functions it calls.

Try adding __stdcall to the C function prototype and see what happens.

0

Check out the Universal DLL function caller, by Paul Caton:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=70195&lngWId=1

It will allow you to call pretty much any type of function from VB6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.