调用API的MessageBox!
using System;
using System.Runtime.InteropServices;
namespace 调用Win32的MessageBox
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Class1.MessageBox(0,"auto","infomation",0);
Class1.MessageBoxA(0,"ANSI我","infomation",0);
Class1.MessageBoxW(0,"Unicode我","infomation",0);
}
[DllImport("user32.dll",CharSet=CharSet.Auto)]
public static extern int MessageBox(int hWnd,string text,string caption,uint type);
[DllImport("user32.dll",CharSet=CharSet.Ansi)]
public static extern int MessageBoxA(int hWnd,string text,string caption,uint type);
[DllImport("user32.dll",CharSet=CharSet.Unicode)]
public static extern int MessageBoxW(int hWnd,string text,string caption,uint type);
}
}
using System.Runtime.InteropServices;
namespace 调用Win32的MessageBox
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Class1.MessageBox(0,"auto","infomation",0);
Class1.MessageBoxA(0,"ANSI我","infomation",0);
Class1.MessageBoxW(0,"Unicode我","infomation",0);
}
[DllImport("user32.dll",CharSet=CharSet.Auto)]
public static extern int MessageBox(int hWnd,string text,string caption,uint type);
[DllImport("user32.dll",CharSet=CharSet.Ansi)]
public static extern int MessageBoxA(int hWnd,string text,string caption,uint type);
[DllImport("user32.dll",CharSet=CharSet.Unicode)]
public static extern int MessageBoxW(int hWnd,string text,string caption,uint type);
}
}
一点说明:为什么在标题中要嵌入英文?原因是为了能够让国外的网友能查询到这篇文章。平常在Google上查资料的时候,经常参考国外网友的博客,帮助我解决了很多问题,所以我也想让他们能够参考我写的内容。当然文中我不可能全部译为英文,所以我尽量把代码粘全,靠代码说话吧。

浙公网安备 33010602011771号