using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; //C#呼叫WinAPI namespace ConsoleApplication2 { class Program { [DllImport("User32.dll", CharSet = CharSet.Unicode)] //程式使用從 User32.dll 程式庫匯入的 MessageBox 方法 public static extern int MessageBox(int h, string m, string c, int type); //MessageBox既定格式 static int Main(string[] args) { string myString; Console.Write("Enter"); myString = Console.ReadLine(); return MessageBox(0, myString, "My Message Box", 0); //# } } }