Public static string getcpuserial (){
String STR = "", strcpu = "", cpuaddress = "0000000000000000 ";
Try {
// Read CPU Information
Process pp = runtime.getruntime(cmd.exe C ("cat/proc/cpuinfo ");
Inputstreamreader IR = new inputstreamreader (pp. getinputstream ());
Linenumberreader input = new linenumberreader (IR );
// Search for the CPU serial number
For (INT I = 1; I <100; I ++ ){
STR = input. Readline ();
If (STR! = NULL ){
// Find the row where the serial number is located
If (Str. indexof ("serial")>-1 ){
// Extract the serial number
Strcpu = Str. substring (Str. indexof (":") + 1,
Str. Length ());
// Remove space
Cpuaddress = strcpu. Trim ();
Break;
}
} Else {
// End of the file
Break;
}
}
} Catch (exception ex ){
// Assign the default value
Ex. printstacktrace ();
}
Return cpuaddress;
}
Note: In some systems, the CPU serial number cannot be obtained, and the result is "0000000000000000"