"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:38**********************************@microsof t.com...
>I have tried everything to import a C++ dll into a C# program without
success. I can import the dll into another C++ program but not a C#
program.
I always get the message that it can't find the function in the specified
dll. So it is finding the dll program but it can't find the entry
statements. I know that in C++ environment a lib file is used for
addressing
the entry statements at link time. Obviously, it does not work in a C#
environment since there are no linker variables. Does anyhow have an
example
of importing a C++ dll into a C# program using the DLLexport function?
Dave
Here's an example. You just put this code somewhere in you C# project. This
is all you need, you don't add an import like you do for C++.
[DllImport("gdi32")]
private static extern int AbortDoc(int hdc);
You need to make sure your C++ dll doesn't mangle the function names it
exports and generally you should make then stdcall. To stop the mangling you
need to add a text file called Exports.DEF and add something like this
Exports
FirstFunctionNameNotToMangle
SecondFunctionNameNotToMangle
etc