基本上我只需要创建一个应用程序(具有某种用户访问权限),其第一个屏幕是一个全屏窗口,如果不输入有效的用户名和密码,则无法最小化或关闭该窗口。类似于 Windows 屏幕保护程序。能做到吗?我应该查看哪些图书馆?这就是我所需要的,如果我的问题不完整或不清楚,请随时提问!
有一次,我用 Java 写了一些东西,你从中can't逃脱。实在是不可能。它适用于 Windows。干得好:
import java.awt.Robot;
import javax.swing.JFrame;
public class WindowsSecurity implements Runnable
{
private JFrame frame;
private boolean running;
public WindowsSecurity(JFrame yourFrame)
{
this.frame = yourFrame;
new Thread(this).start();
}
public void stop()
{
this.running = false;
}
public void run() {
try {
this.terminal.getParentFrame().setAlwaysOnTop(true);
this.terminal.getParentFrame().setDefaultCloseOperation(0);
kill("explorer.exe"); // Kill explorer
Robot robot = new Robot();
int i = 0;
while (running) {
sleep(30L);
focus();
releaseKeys(robot);
sleep(15L);
focus();
if (i++ % 10 == 0) {
kill("taskmgr.exe");
}
focus();
releaseKeys(robot);
}
Runtime.getRuntime().exec("explorer.exe"); // Restart explorer
} catch (Exception e) {
}
}
private void releaseKeys(Robot robot) {
robot.keyRelease(17);
robot.keyRelease(18);
robot.keyRelease(127);
robot.keyRelease(524);
robot.keyRelease(9);
}
private void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (Exception e) {
}
}
private void kill(String string) {
try {
Runtime.getRuntime().exec("taskkill /F /IM " + string).waitFor();
} catch (Exception e) {
}
}
private void focus() {
this.frame.grabFocus();
this.frame.requestFocus();
}
}
Background of this code: I wrote some kind of fake terminal in which I could let appear everything what I wanted. Eg, the stupid Windows messages like: "Keyboard not found, press any key to continue". I used it as a joke on school. Fire up this app and leave the room, it would log out the Windows account automatically after one minute. But I hadn't thought that there would be a teacher that used Ctrl-Alt-Del to kill my application. He left a message in my personal documents in which he wrote what he did and ended his message with "I've beaten you, haha I'm evil". So, I wanted to go in competition with him. And then wrote this code. He tried more than five times in school to escape from the app, but he couldn't (I can't as well :D). Of course he could turn off the machine or log out. But the target was to access my personal documents.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)