如何在Linux,Windows和Mac上使用Java + JNI检索硬盘的唯一ID [英] How can I retrieve a hard disk's unique ID using Java+JNI on Linux, Windows and Mac

查看:83
本文介绍了如何在Linux,Windows和Mac上使用Java + JNI检索硬盘的唯一ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Linux,Windows和Mac上使用Java + JNI检索硬盘的唯一ID?

How can I retrieve a hard disk's unique ID using Java+JNI on Linux, Windows and Mac?

推荐答案

您可以使用Java + JNA( https ://github.com/twall/jna/),但随后您必须弄清楚如何通过使用要支持的每个平台上的本机库来收集信息.

You could use Java+JNA (https://github.com/twall/jna/), but then you'd have to figure out how to gather that information by using native libraries on each of the platforms you'd like to support.

好处是您不必为每个平台编译任何C/C ++代码.如果您决定使用该选项,则其他人可能会告诉您如何使用C/C ++代码/库找出不同平台上的硬盘ID.

The benefit is that you wouldn't have to compile any C/C++ code for each of the platforms. If you decide to go with that option someone else might be able to tell you how to figure out the harddisk IDs on the different platforms using C/C++ code/libraries.

AFAIK,在Linux上,您需要从/proc或/sys中读取某些内容,在Windows上,我将仔细研究MSDN,看看您会发现在Visual Studio(C ++)中可用的内容,对于Mac,则需要其他人填写如果正确执行,可能也应该支持Solaris/BSD.实际上,对于目前大多数与POSIX兼容的操作系统,我认为您应该能够做到一定程度的统一.

AFAIK, on Linux you need to read something from /proc or /sys, on Windows I would look through MSDN and see what you could find that is usable in Visual Studio (C++) and for Mac someone else would have to fill in. Solaris/BSD should probably be supported too if you do it right. In fact, for most of the POSIX-compatible OSes out there I think you should be able to do it somewhat uniformly.

这篇关于如何在Linux,Windows和Mac上使用Java + JNI检索硬盘的唯一ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆