Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
As in C # use the following code:
Cutting simple

Header.h
C#
extern "C" class __declspec (dllexport)  MyClass
public:
{bool Open(int port, int baud);}


Prog.cpp
C#
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:

C#
[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?
Posted
Updated 27-Mar-11 4:42am
v2

Open should not seem an entry point, i think should go well so as is without declaring entry point ..
 
Share this answer
 
I think the problem is that the function you are calling is in a class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900