using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Box
{
class Program
{
[DllImport("User32.dll")]
public static extern int MessageBox(int hand, string custom,string title,int type);
static void Main(string[] args)
{
MessageBox(0, "Good","Greeting" ,0);
Console.ReadKey();
}
}
}
//just less than 10 lines but very useful,needs no form reference
本文提供了一个简单的C#示例程序,演示如何使用P/Invoke调用Windows API中的MessageBox函数来显示一个消息对话框。该程序不需要任何窗体引用,直接在控制台应用程序中实现了消息框的弹出。

被折叠的 条评论
为什么被折叠?



