These problems is often because of name mangling, where SomeFunction becomes _SomeFunction@0 or similar. It is the more strange name _SomeFunction@0 that GetProcAddress needs. Try to use the following command line to figure out which name to send to GetProcAddress:
dumpbin /exports mydll.dll
If you use extern "C" linkage and STDCALL calling convention, you will not get any extra mangling of your name, which makes things simpler. You can also use
syntax in the DEF-file to customize in which way the functions are exported.
List of different exported names I get (this is kind of compiler specific) with different methods:
__declspec(dllexport) void SomeFunction(); // ?SomeFunction@@YAXXZ
extern "C" __declspec(dllexport) void SomeFunction(); // SomeFunction
__declspec(dllexport) void __stdcall SomeFunction(); // ?SomeFunction@@YGXXZ
And with a def-file looking like this:
LIBRARY mydllEXPORTS SomeFunction
it gets the name SomeFunction. You may have to specify the def-file in "Project Properties -> Linker -> Input -> Module Defintion File"
Regarding your warning: /clr means that you use C++ Managed Extensions, which ables you to run managed code and access the objects of the .NET Framework. However, the code automatically run during the initialization of a mixed DLL violates the restrictions for
DllMain. This problem is
not completely solved by Microsoft yet. Is it necessary to use .NET Framework in your DLL?
[Edited by - EliasAE on June 21, 2005 5:56:52 AM]