在这段代码中,怎么对MessageBoxA这个函数进行定义?using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;namespace comtest
{
class test
{
[DllImport("user32.dll")]
public static extern int MessageBoxA(int HWnd,string strMsg,string strCaption,int nType);
}
class Program
{
static void Main(string[] args)
{
int myMsg;
myMsg =MessageBoxA(0,"helllo","test",0);
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;namespace comtest
{
class test
{
[DllImport("user32.dll")]
public static extern int MessageBoxA(int HWnd,string strMsg,string strCaption,int nType);
}
class Program
{
static void Main(string[] args)
{
int myMsg;
myMsg =MessageBoxA(0,"helllo","test",0);
}
}
}
所以,你只需调用就行。
public static extern int MessageBoxA(IntPtr HWnd,string strMsg,string strCaption,int nType);试下,句柄类型要用 IntPtr