using System;using System.Collections.Generic;using System.Text; namespace ConsoleApplication1{ class Program { static void Main(string[] args) { MessageBoxA(0,"Hello World!","My Message Box",0); Console.WriteLine("Over"); Console.Read(); } #region C++ [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern int MessageBoxA( int b, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]string m, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]string c, int type ); #endregion }}
P/Invoke Tutorial: Basics (Part 1):
可以从这里下载现成的开发结构。