http://blog.csdn.net/flyingcloude/article/details/9417825
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class HardWareUtils {
/**
* 获取主板序列号
*
* @return
*/
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();
}
return result.trim();
}
/**
* 获取硬盘序列号
*
* @param drive
* 盘符
* @return
*/
public static String getHardDiskSN(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();
}
/**
* 获取CPU序列号
*
* @return
*/
public static String getCPUSerial() {
String result = "" ;
try {
File file = File.createTempFile( "tmp" , ".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_Processor\") \n"
+ "For Each objItem in colItems \n"
+ " Wscript.Echo objItem.ProcessorId \n"
+ " exit for ' do the first cpu only! \n" + "Next \n" ;
// + " exit for \r\n" + "Next";
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();
file.delete();
} catch (Exception e) {
e.fillInStackTrace();
}
if (result.trim().length() < 1 || result == null ) {
result = "无CPU_ID被读取" ;
}
return result.trim();
}
/**
* 获取MAC地址
*/
public static String getMac() {
String result = "" ;
try {
Process process = Runtime.getRuntime().exec( "ipconfig /all" );
InputStreamReader ir = new InputStreamReader(
process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
while ((line = input.readLine()) != null )
if (line.indexOf( "Physical Address" ) > 0 ) {
String MACAddr = line.substring(line.indexOf( "-" ) - 2 );
result = MACAddr;
}
} catch (java.io.IOException e) {
System.err.println( "IOException " + e.getMessage());
}
return result;
}
public static void main(String[] args) {
System.out.println( "CPU SN:" + HardWareUtils.getCPUSerial());
System.out.println( "主板 SN:" + HardWareUtils.getMotherboardSN());
System.out.println( "C盘 SN:" + HardWareUtils.getHardDiskSN( "c" ));
System.out.println( "MAC SN:" + HardWareUtils.getMac());
}
} |
Linux:
命令:
0、查看CPUID:dmidecode -t processor | grep 'ID'
1、查看服务器型号:dmidecode | grep 'Product Name'
2、查看主板的序列号:dmidecode |grep 'Serial Number'
3、查看系统序列号:dmidecode -s system-serial-number
4、查看内存信息:dmidecode -t memory
5、查看OEM信息:dmidecode -t 11
相关推荐
C# WinForm,获取磁盘容量,Mac地址,CpuID,主板ID,当前登录用户名,计算机名,桌面路径(software/microsoft/windows/currentversion/explorer/shell folders 注册表该路径下的相关信息)等、三层架构、单列,可...
关于获取系统信息,CPUID,硬盘ID,网卡MAC地址的VS2008实现
亲测可用,获取主板,硬盘,CPU,网卡地址等序号,另外还可以获取内存大小,系统登录用户名称,电脑的计算机名称。每个按钮一个功能,信息现在文本框内。源码直接可用,编写软件vb.net 2010 适合新手。
获取cpuid cpu类型 mac 硬盘分区ID 硬盘分区GUID
测试可用的获取硬盘序列号和CPUID的C++代码,包含windows和linux操作系统。 注意:windows vista以上系统需要管理员权限才能获取到硬盘序列号; 做了raid0磁盘阵列的硬盘也不能获取到硬盘序列号,欢迎有相关技术的...
VB源码 读取CPUID 网卡硬盘ID 并有VB 调用DLL例子
获取linux的硬件信息。具体可查看:https://blog.csdn.net/automoblie0/article/details/108076192
获取CPU序列号 硬盘序列号 vs2010工程 支持64位
c++获取cpuid,嵌入汇编语言 xor eax,eax cpuid mov dword ptr vendor_id,ebx mov dword ptr vendor_id[+4],edx mov dword ptr vendor_id[+8],ecx
网上的资源,通过三种方法获取CPUID,用几个C++类实现,并有VC工程演示
vb.net获取硬盘ID厂商信息CPUID 完整项目,建议VS2010打开.
wmi应用(用于获取CPUID和硬盘ID)
获取cpuid,只是这么一个功能 获取cpuid,只是这么一个功能
里面包含C++,Java源代码,在JAVA 中利用JNI加载C++库,读取CPUID.
获取本机cpu id mac地址 硬盘型号
vb.net源码获取硬盘序列号 cpuid 用来加密你的软件
使用C语言获取CPU生产商信息、序列号及MAC地址,内附IP地址获得方法(程序注释内)
[CPUID.rar] - 获取CPU信息/ID号 [CPUID123.rar] - 编程高手 讨论 [GetNo.rar] - 获取硬盘序列号。可以利用在软件保护等模块中。自由下载无需帐号。 [测试CPU的程序.zip] - 测试CPU程序,可以读取CPU的各种...
获取计算机的ID,并通过MD5算法对CPUID进行加密,得到一串编码。
CPUID -MAC-硬盘分区ID获取整合版,工程文件vs2008的。CPU 支持Intel,CPU amd 未测试。。