使用 java/jna 获取硬件信息,适用于所有操作系统

发布于 2024-09-13 09:20:29 字数 203 浏览 3 评论 0原文

你好,我正在尝试编写一个java小程序,它将获取一些硬件信息、mac地址(我已经完成了)、cpuid主板序列号和硬盘驱动器序列号。我知道我需要使用 jna 来做到这一点。我的问题是,c/c++ 有没有办法获取不依赖于平台的信息?我所看到的一切都只能在 Windows 上运行,而我需要它在所有平台上运行。我需要这些信息,以便我可以创建该计算机的唯一 ID。任何帮助或正确方向的指出将不胜感激。

Hi I am trying to write a java applet that will get some hard ware info, mac address(which I have done), cpuid motherboard serial number and hard drive serial number. I know I need to use jna to do this. My question is, is there a way in c/c++ to get that information that is not platform dependent? Everything i have seen would work only on windows, and I need it to work on all platforms. I need this information so I can create a unique id of that computer. any help or a point in the right direction would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌伤浅笑 2024-09-20 09:20:29

我的问题是,c/c++ 中有没有办法获取不依赖于平台的信息?

不可能。哎呀,在同一 PC 市场中,查询(例如 BIOS 版本)对于不同的 MB 制造商/OEM 来说是不同的。如果 PC 仍然有 BIOS,而不是较新的 EFI。

Sun/SPARC 是一个值得注意的例外:它们的 H/W 有一个相对唯一的 ID,主要用于库存目的。它并不完全是唯一的(这就引出了另一点),因为这可能会推断出隐私,而 Sun 别无选择,只能确保它不是全球唯一的。

IOW 硬件的唯一标识在世界许多地方都是非法的,因此不存在可靠(最不便携)的方法来实现您想要的。

我想说绑定到 MAC 地址应该已经足够好了。而且这些信息在几乎所有平台上都相当容易访问。只要您的许可证检查足够宽松,让用户有足够的时间接收新的许可证密钥(在更换硬件的情况下),就不会有什么问题。

My question is, is there a way in c/c++ to get that information that is not platform dependent?

Not possible. Heck, within the same PC market, querying e.g. BIOS version differs from one MB manufacturer/OEM to another. And that if the PC still has BIOS - not the newer EFI.

Sun/SPARCs are notable exception: their H/W has a relatively unique ID, provisioned mainly for inventorial purposes. It is not precisely unique (what brings up another point) as that might infer on privacy and Sun had no choice but to make sure it is not globally unique.

IOW unique identification of the hardware is illegal in many parts of the world, thus no reliable (least portable) method exists to achieve what you want.

I'd say binding to the MAC address should be already good enough. And that information is rather easy to access on pretty much all platforms. As long as your license check would be lenient enough for user to have sufficient time to receive new license key (in case of hardware replacement) there should be few problems.

醉生梦死 2024-09-20 09:20:29

有一个名为 OSHI 的项目旨在实现这一目标。它正在寻找贡献者来编写 *nix 实现。

There's a project called OSHI that aims to do that. It's looking for contributors to write the *nix implementatoin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文