若是須要查看更多文章,請微信搜索公衆號 csharp編程大全,須要進C#交流羣羣請加微信z438679770,備註進羣, 我邀請你進羣! ! !c++
/*c#在調用c++方法或者window api時不能象調用c#自己寫的dll類庫那樣直接經過引用dll就能夠調用相應的方法, 而是要把要引用的dll放到bin中,現經過[DllImport("User32.dll")]引用*/編程
using System;c#
using System.Collections.Generic;api
using System.ComponentModel;微信
using System.Data;spa
using System.Drawing;orm
using System.Linq;blog
using System.Text;string
using System.Threading.Tasks;it
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace API
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("User32.dll")]
public static extern int MessageBoxA(int h, string m, string c, int type);
[DllImport("User32.dll")]
public static extern int MessageBox(int h, string m, string c, int type);
[DllImport("User32.dll")]
public static extern int GetDoubleClickTime();
// public static extern int SendMessageA(int h, int m, int c, int type);
private void button1_Click(object sender, EventArgs e)
{
MessageBoxA(0, "API Message Box", "API Demo", 0);
MessageBox(0, "API Message Box", "API Demo", 0);
MessageBox(0,GetDoubleClickTime().ToString(), "API Demo", 0);
System.Windows.Forms.MessageBox.Show("111");
// SendMessageA(0, 11, 22, 0);
}
}
}