这是我在论坛看到:
package aa;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class BanSupport extends JFrame {
private String keyWord;
private JLabel msg;
public BanSupport(String keyWord) {
super("想禁谁,就可以禁谁");
this.setBounds(200, 200, 500, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
msg=new JLabel("所谓监控用户硬盘,只是个笑话.根本就是公开的API。360是SB ");
this.getContentPane().add(msg);
this.keyWord = keyWord.toLowerCase();
this.check();
}
public void check() {
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
process = runtime.exec("cmd /c Tasklist");
BufferedReader in = new BufferedReader(new InputStreamReader(
process.getInputStream()));
String s = "";
while ((s = in.readLine()) != null) {
s = s.toLowerCase();
if (s.startsWith(keyWord)) {
s = s.substring(0, s.indexOf(".exe") + 4);
JOptionPane.showMessageDialog(this, "您的系统中检测到"+s+",为了保障您的安全,本软件即将退出。请卸载后再使用本检测软件。");
System.exit(-1);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
package aa;
public class Ban360 extends BanSupport {
public Ban360() {
super("360");//这里可以换成QQ
}
public static void main(String[] args) {
Ban360 demo = new Ban360();
demo.setVisible(true);
}
}
但是这个是判断改程序是否运行,而不是qq所说的卸载,但是想法好。
我尝试将process = runtime.exec("cmd /c Tasklist");改为:process = runtime.exec("cmd /c reg query 'HKEY_LOCAL_MACHINE\\SOFTWARE\\360SD'");查询注册表中是否存在360SD来判断,但是读出来的东西却不对,
有尝试了java.util.prefs.Preferences;但是发现只能操作[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs] 里面的注册表信息,难道要引入其他类库,求高手呵
之前process = runtime.exec("cmd /c reg query 'HKEY_LOCAL_MACHINE\\SOFTWARE\\360SD'");中不用加单引号,代码为:
package aa;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class BanSupport extends JFrame {
private String keyWord;
private JLabel msg;
public BanSupport(String keyWord) throws IOException {
super("想禁谁,就可以禁谁");
this.setBounds(200, 200, 500, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
msg=new JLabel("所谓监控用户硬盘,只是个笑话.根本就是公开的API。360是SB ");
this.getContentPane().add(msg);
this.keyWord = keyWord.toLowerCase();
this.check();
}
public void check() throws IOException {
Runtime runtime = Runtime.getRuntime();
Process process = null;
process = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\"+keyWord);
BufferedReader in = new BufferedReader(new InputStreamReader(
process.getInputStream()));
while (in.readLine() != null) {
JOptionPane.showMessageDialog(this, "您的系统中检测到"+keyWord+",为了保障您的安全,本软件即将退出。请卸载后再使用本检测软件。");
System.exit(-1);
}
in.close();
process.destroy();
}
}
package aa;
import java.io.IOException;
public class Ban360 extends BanSupport {
public Ban360() throws IOException {
super("aa");//这里可以换成Tencent
}
public static void main(String[] args) throws IOException {
Ban360 demo = new Ban360();
demo.setVisible(true);
}
}
欢迎: