using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Messages
{
class Program
{
//注意DllImport是一个Attribute Property (属性的性质),在System.Runtime.InteropServices命名空间中定义
//extern与DllImport一起使用时必须再加上一个static修饰符
[DllImport("User32.dll")]
public static extern int MessageBox(int Handle, string Message, string Caption, int Type);
static int Main()
{
string inPut;
Console.Write("请输入您的名字: ");
inPut = Console.ReadLine();
return MessageBox(0, inPut, "你好欢迎光临", 0);
}
}
}
|
|