① java 能不能获取CPU的ID号,硬盘的序列号
public class CpuUtil {
public static void main(String[] args) throws IOException {
long start = System.currentTimeMillis();
Process process = Runtime.getRuntime().exec(
new String[] { "wmic", "cpu", "get", "ProcessorId" });
process.getOutputStream().close();
Scanner sc = new Scanner(process.getInputStream());
String property = sc.next();
String serial = sc.next();
System.out.println(property + ": " + serial);
System.out.println("time:" + (System.currentTimeMillis() - start));
}
}
public class DiskUtil {
public static String getSerialNumber(String drive) {
String result = "";
try {
File file = File.createTempFile("realhowto",".vbs");
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
String vbs = "Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
+"Set colDrives = objFSO.Drives\n"
+"Set objDrive = colDrives.item(\"" + drive + "\")\n"
+"Wscript.Echo objDrive.SerialNumber"; // see note
fw.write(vbs);
fw.close();
Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null) {
result += line;
}
input.close();
}
catch(Exception e){
e.printStackTrace();
}
return result.trim();
}
public static void main(String[] args) {
String sn = DiskUtil.getSerialNumber("C");
System.out.println(sn);
}
② java如何获取本机主板序列号
public static String getMotherboardSN() {
String result = "";
try {
File file = File.createTempFile("realhowto", ".vbs");
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
String vbs = "Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n"
+ "Set colItems = objWMIService.ExecQuery _ \n"
+ " (\"Select * from Win32_BaseBoard\") \n"
+ "For Each objItem in colItems \n"
+ " Wscript.Echo objItem.SerialNumber \n"
+ " exit for ' do the first cpu only! \n" + "Next \n";
fw.write(vbs);
fw.close();
Process p = Runtime.getRuntime().exec(
"cscript //NoLogo " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line;
while ((line = input.readLine()) != null) {
result += line;
}
input.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(result);
return result.trim();
}
public static void main(String[] args)
{
getMotherboardSN();
}
这个是我在网上找的,但是只能在windows下获得主板序列号,在linux下就不行。我愁~在linux下如何获得主板序列号呢。
③ linux怎么查看cpu编号查询
都在/proc/ 下面 cpu信息在/proc/cpuinfo 启动时间在/proc/uptime 单位是s /proc/stat 里面有cpu执行的时间,用户态,系统态,空闲都有
④ linux java怎么获取cpu
参考一下吧,代码在附件里面,java自带的
⑤ 怎样用java 获取 硬盘 cpu 序列号,可调用dll实现
我是通过一个外部的JAR包来间接来获得DLL文件的句柄 的,它就是jacob了,这是java com brige的简写,呵呵, 这个名称起得非常形象吧,我用的版本是jacob 1.9的,你可以到它的官方网站去下载,下载回来的压缩包中会有两个文件我们需要用到的,一个是jacob.dll,一个是jacob.jar,jacob.dll可以将它复制到系统的system32目录下,而jacob.jar文件,直接将它加入到项目的库中就可以了。这两项准备工作完成后,就可以开始尝试调用了。
新建一个类,引入jacob.jar中的两个类,
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
然后通过dll的ControllerId来读取DLL文件
public class Print {
private ActiveXComponent printController = null;
private Dispatch printObj = null;/*** 默认controllerId的方法*/public Print(){try{printController = new ActiveXComponent(POSControler.Controler);
printObj = (Dispatch)printController.getObject();
}catch(Exception e){
printObj = new Dispatch();
如果方法dll中的方法是空参数时,直接call一下就可以了,如
Dispatch.call(printObj,setDefaultFont);而调用有参数的方法时,则需要将参数在后面依次传入,注意按顺序噢:
⑥ Linux怎么过去cpu的序列号
同楼上的,你执行这个命令需要root权限,你这个返回是你的权限不够的意思。
⑦ 如何通过编程读取CPU的序列号
java是可以获取的但是比较麻烦但是还是感觉用C比较方便privatevoidGetInfo(){stringcpuInfo="";//cpu序列号ManagementClasscimobject=newManagementClass("Win32_Processor");ManagementObjectCollectionmoc=cimobject.GetInstances();foreach(ManagementObjectmoinmoc){cpuInfo=mo.Properties["ProcessorId"].Value.ToString();Response.Write("cpu序列号:"+cpuInfo.ToString());}//获取硬盘IDStringHDid;ManagementClasscimobject1=newManagementClass("Win32_DiskDrive");=cimobject1.GetInstances();foreach(ManagementObjectmoinmoc1){HDid=(string)mo.Properties["Model"].Value;Response.Write("硬盘序列号:"+HDid.ToString());}//获取网卡硬件地址=newManagementClass("Win32_NetworkAdapterConfiguration");=mc.GetInstances();foreach(ManagementObjectmoinmoc2){if((bool)mo["IPEnabled"]==true)Response.Write("MACaddress\t{0}"+mo["MacAddress"].ToString());mo.Dispose();}}只有Pentium3能够读取cpu的“序列号”,后来的cpu都没有装配这个信息。一般cpu只能读取cpu的“信息”而不是“序列号”
⑧ Java如何获取CPU标识符
可尝试通过System.getProperties() 这类API获取:
System.getProperty("os.arch") -- cpu架构 ,如x86
os.name --如Windows XP
os.version -- 操作系统版本号
如果还无法满足,可以根据系统的不同,利用Runtime入口去执行命令来获取,比如:
linux 下 可以执行如:
Runtime.getRuntime().exec("cat /proc/cpuinfo |grep vender_id");
之类的语句进行获取
⑨ 如何获取cpu序列号
一、CPU都有一个唯一的ID号,称CPUID,是在制造CPU的时候,由厂家置入到CPU内部的。
二、查看方法:
1、右点开始,选运行,并输入CMD。
三、作用和意义:
由于CPU外在的所有标记、符号,都是可以人为打磨,而CPUID却是终身不变的,只能用软件读出ID号;因此,利用这个原理,CPU ID工具可以显出CPU的确切信息,包括移动版本、主频、外频、二级缓存等关键信息,从而查出超频的CPU,并且醒目地显示出来。
⑩ linux下java怎么获取CPU和硬盘序列号
JDK 目录 jdk1.6.0_21\demo\management\MemoryMonitor 位置 jar demo源码自参考