通过判断进程判断系统正在运行某个软件
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。 ");
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+",为了保障您的安全,本软件即将退出。请关闭"+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);
}
}
判断注册表查看安装了某款软件
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。");
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+",为了保障您的安全,本软件即将退出。请卸载"+s+"后再使用本检测软件。");
System.exit(-1);
}
in.close();
process.destroy();
}
}
package aa;
import java.io.IOException;
public class Ban360 extends BanSupport {
public Ban360() throws IOException {
super("sd360");//这里可以换成Tencent
}
public static void main(String[] args) throws IOException {
Ban360 demo = new Ban360();
demo.setVisible(true);
}
}