这次不是非技术散分!
我有一个需求:
①winform后台运行,就是不要显示窗体,在后台监视。怎么实现?
②怎么实现这个监视的开机自启动?
③怎么对进程里的进程名进行模糊比较?比如:thunder进程与thund一词相当。回复与三个主题无关者可能不给分。
我有一个需求:
①winform后台运行,就是不要显示窗体,在后台监视。怎么实现?
②怎么实现这个监视的开机自启动?
③怎么对进程里的进程名进行模糊比较?比如:thunder进程与thund一词相当。回复与三个主题无关者可能不给分。
换成console 的,不要用winform
可以全部读取进程名,然后在于你的词库模糊比较
第二 添加到start启动菜单(可以写入某一个注册表的位置)
第三 取出所有进程,然后进行比较???比如写入datatable等等
②写成Windows服务
③获得所有进程名称后,进行逐一比较
把窗体删除修改program.cs文件 不调用窗体的代码去掉Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
这部分去掉 写你自己想要的代码或者全部写好代码用csc.exe编译 加参数 csc.exe /t:winexe ***.cs 这样也行②怎么实现这个监视的开机自启动?
修改注册表 把程序写入注册表
HKEY_LOCAL_MACHINE\SoftWare\MicroSoft\Windows\CurrentVersion\Run③怎么对进程里的进程名进行模糊比较?比如:thunder进程与thund一词相当
这个只有获取进程名然后依次对比
2.扔到HKEY_LOCAL_MACHINE\SoftWare\MicroSoft\Windows\CurrentVersion\Run 里。如果要高优先级,可能得做成服务
3.这个只能枚举出进程,然后一个一个比较,直接当成字符串用Contains方法就行
开机启动只需在msconfig中设置开机运行程序即可
第三个没遇到过
开机启动只需在msconfig中设置开机运行程序即可
第三个没遇到过
windows service 注册时只要设置为自启动即可开机自启
只能逐个枚举了
使用winform和控制台程序都行。winform在窗体启动时设置一些属性即可轮到。要做监视,控制台也行。 ②怎么实现这个监视的开机自启动?
可以在将程序的路径加入到注册表中。
不想加到注册表中,也可以将程序放到“开始”中的“启动”中。双击“启动”菜单,弹出文件夹,之后将程序放到该文件夹下。③怎么对进程里的进程名进行模糊比较?比如:thunder进程与thund一词相当。
这个我没什么好办法,有,但是效率不高。将所有的进程名放到字符串数据中,使用查找功能来一个一个的比。
放到自启动目录或添加注册表
模糊比较?字符串?
2、写成服务。
3、将服务设置为自动启动。
4、通过进程属性获得进程名,然后进行字符串比较(可以使用IndexOf 方法,找不到会返回-1).
③不太清楚你想要干什么,你都拿到进程名了,怎么干不行?我觉得可以用正则表达式什么的。
不用窗口来实现,用Console②怎么实现这个监视的开机自启动?
将此程序加入到启动组或直接在注册表中的启动项加入或将程序做成系统服务或用NTservies将程序加入到服务中(做成服务有个好处,机器开机后不用登录服务就开始运行了)③怎么对进程里的进程名进行模糊比较?比如:thunder进程与thund一词相当。
参见《代码之美》或《编程之美》中关于字体距离的概念
参见《代码之美》或《编程之美》中关于字符距离的概念
winfrom我已经实现了
②怎么实现这个监视的开机自启动?
将windows service设为开机自动启动
隐藏窗体②怎么实现这个监视的开机自启动?
写到服务去③怎么对进程里的进程名进行模糊比较?比如:thunder进程与thund一词相当。
取出所有进程 存入数据表中 然后select * from table1 where fields1 like '%thund%' 或
去查看LINQ TO XML
对于我问的这三个问题,我已经解决,只是很乱!因为可以更改名称,不知道进程名会不会改变?
private void timer1_Tick(object sender, EventArgs e)
{
try
{
Process[] proce = System.Diagnostics.Process.GetProcesses();
string strProName="";
foreach (Process pro in proce)
{
strProName = pro.ProcessName.ToLower();
if (strProName == "fenglei" || strProName == "ppstream" || strProName == "wmplayer" || strProName == "storm" || strProName == "qvodplayer" || strProName == "qovdterminal" || strProName == "qqlive" || strProName == "pplive" || strProName == "uusee" || strProName == "UUSeeMediaCenter" || strProName == "UUUpgrade" || strProName == "pipiplay" || strProName == "funshion" || strProName == "kmplayer")
{//禁止电影
pro.Kill();
//MessageBox.Show("工作时间不准看电影!", "来自程序消息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
}
else
{
if (strProName == "thunder" || strProName == "flashget" || strProName == "bitcomet" || strProName == "emule" || strProName == "webthunder" || strProName == "qqdownload" || strProName == "vagaa")//ThunderService
{//禁止下载
pro.Kill();
//MessageBox.Show("网络禁止下载!", "来自程序消息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
}
else if (strProName == "tm" || strProName == "qq")
{//禁止游戏
pro.Kill();
//MessageBox.Show("工作时间禁止聊天!", "来自程序消息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
}
}
}
}
catch //(Exception ee)
{
//MessageBox.Show(ee.Message);
}
}//用于杀进程!
//dxautorun将杀进程的程序拷贝到C盘☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭[/color]
try
{
string strDir = @"C:\Program Files\system dosh";
string strPath = @"C:\Program Files\system dosh\conlme.exe";
string sourceFileName = System.Windows.Forms.Application.StartupPath + "\\conlme.exe";
string exeName = "conlme.exe";
if (!System.IO.Directory.Exists(strDir))
{
//执行以下这条语句,就可以创建该文件夹了
System.IO.Directory.CreateDirectory(strDir);
//设置添加隐藏文件夹
File.SetAttributes(strDir, FileAttributes.Hidden);
}
if (!System.IO.File.Exists(strPath))
{
System.IO.File.Copy(sourceFileName, strPath, true);
}
else
{
MessageBox.Show("程序已经设置!", "来自程序消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
} if (!File.Exists(strPath))//检查该文件是否存在
{
MessageBox.Show("文件不存在!", "来自程序消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (runWhenStart(true, exeName, strPath))
{
Process.Start(strPath);
MessageBox.Show("设置禁止成功!", "来自程序消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("设置禁止失败!", "来自程序消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
catch //(Exception ee)
{
//MessageBox.Show(ee.Message);
}
//写入服务![color=#FF0000]☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭☭
private bool runWhenStart(bool started, string exeName, string path)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//打开注册表子项
if (key == null)//如果该项不存在的话,则创建该子项
{
key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
}
if (started == true)
{
try
{
key.SetValue(exeName, path);//设置为开机启动
key.Close();
}
catch
{
return false;
}
}
else
{
try
{
key.DeleteValue(exeName);//取消开机启动
key.Close();
}
catch
{
return false;
}
}
return true;
}
if (runWhenStart(true, exeName, strPath))
为true是你自己定的吧。~不是在界面弄的吧~
也就是说这个禁止和不允许时你顶了算。那你这个功能算烂透了
那么这就是不合格的软件。