Interoperability with MFC dll

R

Ronny

I try to work with Interoperability and import to my dotnet C# application,
a global exported function from my own MFC regular dll.
Walking through some examples I saw the examples that use win32 Windows
function like MessageBox(...) but never encounter my need(global exported
function with _declspec(dllexport) prefix).
Can someone direct me please?
Regards
Ronny
 
M

Mark Salsbery [MVP]

Ronny said:
I try to work with Interoperability and import to my dotnet C#
application, a global exported function from my own MFC regular dll.
Walking through some examples I saw the examples that use win32 Windows
function like MessageBox(...) but never encounter my need(global exported
function with _declspec(dllexport) prefix).
Can someone direct me please?


Here's an example...

// In a cpp file in the DLL project (MyDLL.dll)

extern "C" __declspec(dllexport) int NativeDLLFunc(int i)
{
return i + 5;
}



// C#

class MyClass
{
[DllImport("PathToMyNativeDLL\\MyDLL.dll")]
public static extern int NativeDLLFunc(int i);


void SomeMethod()
{
int i = NativeDLLFunc(3);
}
....



Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top