using System; using System.Runtime.InteropServices; namespace 调用非托管项目demo { class Program { static void Main(string[] args) { Win32.MessageBox(0, "Hello I am Kun", "stm32", 0); } public class Win32 { [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr MessageBox(int hWnd, String text,String caption, uint type); } } }
运行结果: