Page 1 of 1

"Run time Error '49'" "Bad DLL calling conve

Posted: Thu Jun 10, 2004 2:12 pm
by aUDIOopOND
Using Visual Studio 6 I declare a C function in a DLL as

extern "C" TEST_API int fname(long nValue);

in VB I Declare thje DLL function as:

Private Declare Function fname Lib "O:\Documents and Settings\...\test.dll" _
(ByVal nValue As Long) As Integer

and call it as:

temp = fname(numValue)

where numValue is of type Long.

On doing this I receive the error "Run time Error '49'" "Bad DLL calling convention"

What is wrong with this??

Re:"Run time Error '49'" "Bad DLL calling co

Posted: Thu Jun 10, 2004 2:59 pm
by mystran
Please see this thread.

Re:"Run time Error '49'" "Bad DLL calling co

Posted: Thu Jun 10, 2004 6:37 pm
by AudioOPond
Thanks, but I do not think my problem is related to the name of the function. The extern "C" causes standard C function names to be used, hence no name mangling, and when I call a function with no arguments I have no problem. My problem is purely related to the nature of the arguments in the function. In both VB and the DLL I have a single ByVal long argument, so even parameter ordering cannot be a problem (I think).

See below for the dumpbin output of the /EXPORTs for the DLL

Dump of file singen.dll
File Type: DLL


1 0 0000101E ??0CSingen@@QAE@XZ
2 1 0000100F ??4CSingen@@QAEAAV0@ABV0@@Z
3 2 00032778 ?nSingen@@3HA
4 3 00001023 fnSingen
5 4 00001014 fnSingen1
6 5 00001019 fnSingen2
7 6 00001005 get42

Note the last 4 non-mangled export symbols.

Why are the arguments causing me problems?

Re:"Run time Error '49'" "Bad DLL calling co

Posted: Thu Jun 10, 2004 7:16 pm
by AudioOPond
Doh! My Bad. The advice works perfectly when I follow the instructions properly. Funny how the old fashioned ways are always the bast ways.

Thanks

Audio