我想知道如何获取我的应用程序安装的电脑的唯一标识符。我在here中关注了一些问题.但我无法利用它。请让我知道如何使用示例代码或任何有用的链接在 Java 中执行此操作。(至少如何在 Java 中获取系统详细信息)谢谢
最佳答案
不稳定的想法和不稳定的输出,请注意,您收到了正确的计算机和用户信息、PC 的唯一标识符以及更可靠的结果,返回硬件防火墙后面的 Intranet(而不是 Interner)中的计算机
问题:
- IP可以更改
- MAC 可以别名
Novell、AD 可以添加详细的用户信息,并且某些计算机(所有 HP/Compaq)不返回硬件配置
private void getPcInfo() {
Enumeration<?> interfaces = null;
try {
PcLogName = InetAddress.getLocalHost().getHostName();
InetAddress local = InetAddress.getLocalHost();
InetAddress[] all_local = InetAddress.getAllByName(local.getHostName());
LinkedList<InetAddress> list = new LinkedList<InetAddress>();
//System.out.println("PcLogName " + PcLogName);
//System.out.println("PcLogName " + list);
try {
interfaces = NetworkInterface.getNetworkInterfaces();
////System.out.println("NetworkInterface " + interfaces);
} catch (SocketException ex) {
Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
}
while (interfaces.hasMoreElements()) {
NetworkInterface card = (NetworkInterface) interfaces.nextElement();
////System.out.println("NetworkInterface NetCard " + card);
Enumeration<?> addresses = card.getInetAddresses();
////System.out.println("NetCard Name " + addresses);
if (addresses == null) {
continue;
}
while (addresses.hasMoreElements()) {
InetAddress address = (InetAddress) addresses.nextElement();
list.add(address);
//System.out.println("Add Address : " + address);
}
}
//System.out.println("IP's Address " + list);
} catch (UnknownHostException ex) {
Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
}
PcLogUser = System.getProperty("user.name");
//System.out.println("PcLogUser : " + PcLogUser);
WinUser = System.getenv("USER");
//System.out.println("WinUser : " + WinUser);
WinDsn = System.getenv("USERDOMAIN");
//System.out.println("WinDsn : " + WinDsn);
WinUserName = System.getenv("USERNAME");
//System.out.println("WinUserName : " + WinUserName);
WinPath = System.getenv("USERPROFILE");
//System.out.println("WinPath : " + WinPath);
ComputerName = System.getenv("COMPUTERNAME");
//System.out.println("ComputerName : " + ComputerName);
PcInfo = System.getenv("System Model");
//System.out.println("PcInfo : " + PcInfo);
}
如何获取MAC例如here
关于java - 如何获取系统数据并使我的应用程序针对操作系统独一无二,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7372151/