菜鸟求教:杀QQ游戏进程问题
因为就一台电脑,女朋友老跟我抢用玩QQ斗地主,倍感深恶痛绝……
无奈,不懂程序,从网上一搜,照COPY,七拼八凑,组装成一小程序,
代码如下:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
namespace tasklist
{
class Program
{
static void Main( )
{
ProcexpRefresh();
}
private void ProcexpRefresh(string[] args)
{
//创建新的 Process 组件的数组
Process[] myProcesses = Process.GetProcesses();
foreach (Process myProcess in myProcesses)
{
if (myProcess.ProcessName == "ddzrpg")
{
MessageBox.Show("暂停游戏!","抱歉",MessageBoxButtons.OK, MessageBoxIcon.Stop);
Process p = Process.GetProcessById(myProcess.Id);
if (p == null)
return;
if (!p.CloseMainWindow())
p.Kill();
p.WaitForExit();
p.Close();
}
}
}
private void timer1_Tick(object sender, System.EventArgs e)
{ //定时刷新进程
ProcexpRefresh();
}
}
}
编译错误:
“ProcexpRefresh”方法没有采用“0”个参数的重载
网上找说是最基本的OOP思想,我没弄过这玩意,不懂,请高手指点,不甚感激……