如何使JAVA编写的软件与硬盘注册绑定?!

zcs9712 2008-02-02 11:01:22
我写了一个企业管理软件,如何与计算机的硬盘进行注册绑定,绑定后才能运行该软件,希望高手进行指点一下小弟!谢谢
...全文
490 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jyh149129 2008-02-03
  • 打赏
  • 举报
回复
如果会delphi的话,几分钟就搞定,让后java来调用.
不过别人随便把你的class反编译一下,绕过检查.这样的加密也没什么用了.
guoqiangone 2008-02-03
  • 打赏
  • 举报
回复
学习,
  • 打赏
  • 举报
回复
楼上的写的是MAC地址的..
一般绑定硬盘是读取硬盘号...JVM应该没有类似的功能...

你可以用C++写一个读取硬盘信息的DLL.然后JAVA调用至于怎么注册..呵呵..只要把硬盘信息读取出来..相信其它的你会搞定
dracularking 2008-02-03
  • 打赏
  • 举报
回复
获取Ethernet Adapter和PPP Adapter的Physical Address

import 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());
}
}
zcs9712 2008-02-02
  • 打赏
  • 举报
回复
怎么来获取硬盘的ID号呢
robin1210 2008-02-02
  • 打赏
  • 举报
回复
不是打击你啊,获取硬盘序列号需要系统底层的支持,网上有卖的。关键是那个DLL库,你考虑考虑买一个吧
老紫竹 2008-02-02
  • 打赏
  • 举报
回复
C/S的吗?用现成的加密软件吧! 去搜艘!
zs_han 2008-02-02
  • 打赏
  • 举报
回复
与硬件帮定,你读取硬件的信息来判断不就可以了吗?

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧