As in C # use the following code:
Cutting simple
Header.h
extern "C" class __declspec (dllexport) MyClass
public:
{bool Open(int port, int baud);}
Prog.cpp
extern "C" __declspec (dllexport) bool MyClass::Open(int port, int baud)
{
char COM_string[20];
sprintf(COM_string,"\\\\.\\COM%d", port);
m_hFile = CreateFile(COM_string, GENERIC_READ|GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);
if(m_hFile == INVALID_HANDLE_VALUE)
{
return false;
}
}
This is compiled into the library MyLybrary.dll
In C # I use the attribute:
[DllImport("MyLybrary", EntryPoint = "Open")]
public static extern bool Open(int port, int baud);
But the call Open() to get the message: Can not find an entry point Open.
The problem is the use of Class MyClass?