How to call C++ DLL in C#

前端 未结 3 505
暗喜
暗喜 2020-11-30 04:53

I have written a DLL in dev C++. The DLL\'s name is \"DllMain.dll\" and it contains two functions: HelloWorld and ShowMe. The header file looks lik

3条回答
  •  忘掉有多难
    2020-11-30 05:38

    using System;
    using System.Runtime.InteropServices;
    
    namespace MyNameSpace
    {
        public class MyClass
        {
            [DllImport("DllMain.dll", EntryPoint = "HelloWorld")]
            public static extern void HelloWorld();
    
            [DllImport("DllMain.dll", EntryPoint = "ShowMe")]
            public static extern void ShowMe();
        }
    }
    

提交回复
热议问题