
Calling 32-bit DLL function from 32-bit VB4 app
: The change of name of the function is because C++ compilers
: change the names of functions to add stronger type checking. The
: easiest way to change this ( if you don't use C++ features) is to
: change your build options and define the function using
: extern "C"
: Also, any functions for Visual Basic use should be declared
: using PASCAL to modify any return type (even void). Microsoft's
: Tech Support even recommends using a module definition file rather
: than declspec (dllexport) if you are writing DLL functions for VB.
:
: --
: Ron Ruble Consulting
: Application Development
: Flames cheerfully ignored.
: Maximize bandwidth; teach a newbie the usenet
I haven't read the original post but I think this info may be incorrect
(along with the other postings regard C++ name mangling). When C program
is written with the extension .c and utilising no C++ features it will be
treated as a C file - C++ name mangling will NOT occur. The problem
of name changing is because of the _stdcall specifier. So if you have a
function foo declared as followed:
DllExport void _stdcall foo(int i) {.....}
OR
DllExport void WINAPI foo(int i) {...}
as a parameter and an int is _4_ bytes long. If foo took two integer
_stdcall specifier. Just look up _stcall in the online documentation - it
specificall says that it will add this to the end of the function names.
If you dont' use _stdcall then your get bad calling convention so you
really do need to specify it. The problem is that VB doesn't expect the
functions to be named in such a way (Microsoft can't even get their
programs to adhere to a standard!) so you have to alias the function as
much difference.
SImon