How to create dll in C++ for using in C#

前端 未结 4 1210
失恋的感觉
失恋的感觉 2020-12-28 09:27

I\'ve a little question to ask you.

I have one C++ source and one header files. The C++ file uses windows.h library, makes operations using serial port(basic operati

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 10:00

    You need to compile your C++ code into a dynamic link library and do the following in C#:

      class MyClass
      {
      [DllImport("MyDLL.dll")]
      public static extern void MyFunctionFromDll();
    
            static void Main()
            {
                  MyFunctionFromDll();
            }
      }
    

提交回复
热议问题