Reports on answers to my --- Question: How do you call a Visual C++ (DLL)
Reports on answers to my --- Question: How do you call a Visual C++ (DLL)
function from Visual Basic
Quote:
>> you have to add a .def file to your C++-Project and write the following
lines:
EXPORTS
fnMyDll
and your C++-declaration should look like
extern "C" int WINAPI fnMyDll(void)
{
return 770;
Quote:
}
That method works!
-----------------------------------------------------------------------
correct with
_declspec( dllexport ) - as long as you use a DEF file containing :
' EXPORTS
fnMyDll '
All the articles in my MSDN CD help (Ver 6.0) under the title "Export from a
DLL " say that if you use "__declspec( dllexport )" (which was the original
method that I tried), then you don't need to use a DEF file (with regards to
exporting). For some reason out of all the things I did to get the DLL
working, going against the documentation was not something that I tried,
even though I had suspected that maybe that was the problem. Wasted hours!
-----------------------------------------------------------------------
* To the Michka Kaplan who suggested as follows:
Quote:
>> Read this article in the MSDN....Q106553
The article is an old one. It suggests declaring DLL functions as "__export
CALLBACK " and provides an enormous DEF file. I did not try it.
-----------------------------------------------------------------------
Quote:
>> You need to use the StdCall parameter passing method.
That method did not work for me, for some reason.
-----------------------------------------------------------------------
* CONCLUSION
Now that I see that "__declspec( dllexport )" does in fact work if you
supply a def file, then I will stick to that since it is basically the
solution autogenerated by the MSVC DLL wizard. (If I had wanted the MFC
version for DLLs then it would have autogenned also the DEF file and I would
never have run into the problem).
Thanks everybody.
Avraham.