Target platform: Visual C# 2010 Express
Source platform: Visual C++ 2005 Professional ( to generate the DLL file )
[Part A] : To create a native C library (.dll)
1. new project --> Win32 project ( Note: not MFC --> MFC DLL ) --> in the application setting page,
select the below properties: (type:DLL), (additional options:Export symbols)
2. in your header file of the project, define the export function like this:
( DLLRESPIRATION0927 is my project name.)
// my export method
extern "C" DLLRESPIRATION0927_API int __stdcall fnRespiration( int count,short buffer[] );
Note:
if you don't add the macro
extern "C", Visual C# will appear the error message: "Unable to find an entry point", when you call this method.
if you don't add the macro __stdcall, the C# program can't find this function.
About extern "C",
because the C++ has the overloading function, it won't be supported by C.
We use this macro to close the overloading mechanism in C++ compiler.
3. in the .cpp file, declare the function like this:
DLLRESPIRATION0927_API int __stdcall fnRespiration(int count,short buffer[])
{
return 0;
}