- A+
如果需要查看更多文章,请微信搜索公众号 csharp编程大全,需要进C#交流群群请加微信z438679770,备注进群, 我邀请你进群! ! !
/*c#在调用c++方法或者window api时不能象调用c#本身写的dll类库那样直接通过引用dll就可以调用相应的方法, 而是要把要引用的dll放到bin中,现通过[DllImport("User32.dll")]引用*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}
}