代码如下
[DllImport("Coredll.dll", EntryPoint = "GetTickCount")]
private static extern int GetTickCount();
int dstart = GetTickCount();
//这里填写要执行的代码
int dend = GetTickCount();
string strtime = (dend - dstart).ToString();
strtime += "毫秒";
MessageBox.Show(strtime);