项目做好了,想发布了个单机版,安装到cd上去,下了个setup factory 7.0,我想通过一张盘只能安装到一台电脑上,通过电脑的mac地址来判断,然后我加密提示用户,用户把加密后mac地址发给我,我在通过加密,在发给用户,用户通过我给的序列号来进行安装,在程序用会将我发给用户的序列号进行解码成mac地址,将本机的地址和解码的mac地址进行比对,如果相同就可以安装,不同则不能安装,大概就这个思路,不过我不知道怎末去做,setupfactory的编程不大懂,有没有高手,帮帮忙,很急,答出马上给分,谢谢!!!!!!!!!
import java.util.*;
import java.util.regex.*;
public class NetID {
String IPCONFIG_COMMAND_WIN = "ipconfig /all";
boolean realMac = true;
String unique = "";
public static String getMacAddress() {
NetID hwid = new NetID();
return hwid.getUnique().trim();
}
private String getUnique() {
String os = System.getProperty("os.name");
if (os.startsWith("Windows")) {
return getUniqueWindows();
}else {
return "";
}
}
private String getUniqueWindows() {
String ipConfigResponse = null;
try {
ipConfigResponse = runConsoleCommand(IPCONFIG_COMMAND_WIN);
}
catch (IOException e) {
e.printStackTrace();
}
StringTokenizer tokenizer = new StringTokenizer(ipConfigResponse, "\n");
while (tokenizer.hasMoreTokens()) {
String line = tokenizer.nextToken().trim();
int macAddressPosition = line.indexOf(":");
if (macAddressPosition <= 0) {
continue;
}
String macAddressCandidate = line.substring(macAddressPosition + 1).
trim();
if (isMacAddWin(macAddressCandidate)) {
if (realMac == true) {
generateUnique(macAddressCandidate);
}
else {
realMac = true;
}
}
}