我写了一个企业管理软件,如何与计算机的硬盘进行注册绑定,绑定后才能运行该软件,希望高手进行指点一下小弟!谢谢

解决方案 »

  1.   

    不是打击你啊,获取硬盘序列号需要系统底层的支持,网上有卖的。关键是那个DLL库,你考虑考虑买一个吧
      

  2.   

    如果会delphi的话,几分钟就搞定,让后java来调用.
    不过别人随便把你的class反编译一下,绕过检查.这样的加密也没什么用了.
      

  3.   

    获取Ethernet Adapter和PPP Adapter的Physical Addressimport java.io.*;
    import java.util.*;
    import java.util.regex.*;public class Test {
        String IPCONFIG_COMMAND_WIN = "ipconfig       /all ";    boolean realMac = true;    String unique = " ";    public static String getMacAddress() {
            Test hwid = new Test();
            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();
            }        // 按行分割结果字符串,并循环判断每个字符串直到找出 Mac 地址
            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();            // 检查 macAddressCandidate 中内容是否为真实网卡 Mac 地址,根据 Mac 地址计算出唯一标识。
                if (isMacAddWin(macAddressCandidate)) {
                    if (realMac == true) {
                        generateUnique(macAddressCandidate);
                    }
                    else {
                        realMac = true;
                    }
                }
            }        return unique;
        }    /**
         * 运行控制台命令,返回结果字符串
         * 
         * @param command
         *            String
         * @return String
         * @throws IOException
         */
        private String runConsoleCommand(String command) throws IOException {
            Process p = Runtime.getRuntime().exec(command);
            InputStream stdoutStream = new BufferedInputStream(p.getInputStream());        StringBuffer buffer = new StringBuffer();
            while (true) {
                int c = stdoutStream.read();
                if (c == -1) {
                    break;
                }
                buffer.append((char) c);
            }
            String outputText = buffer.toString();        stdoutStream.close();        return outputText;
        }    /**
         * 对输入参数进行检查,符合正则表达式的为 windows 平台下有效 Mac 地址
         * 
         * @param macAddressCandidate
         *            String
         * @return boolean
         */
        private boolean isMacAddWin(String macAddressCandidate) {
            Pattern macPattern = Pattern
                    .compile("[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}");
            Matcher m = macPattern.matcher(macAddressCandidate);
            return m.matches();
        }    /**
         * 对输入参数进行检查,符合长度的为 MAC OS X 下有效网卡 Mac 地址
         * 
         * @param macAddressCandidate
         *            String
         * @return boolean
         */
        private boolean isMacAddOSX(String macAddressCandidate) {
            if (macAddressCandidate.length() != 17) {
                return false;
            }
            else {
                return true;
            }
        }    /**
         * 产生 Unique
         * 
         * @param macAddress
         *            String
         */
        private void generateUnique(String macAddress) {
            if (unique == " ") {
                unique += macAddress;
            }
            else {
                unique += "# ";
                unique += macAddress;
            }
        }    public static void main(String[] args) {
            System.out.println(Test.getMacAddress());
        }
    }