免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

硬盤序列號java代碼 硬件編碼和硬盤序列號

跪求在JAVA里如何獲得CPU的序列號,和硬盤的序列號。

利用Runtime call操作系統的命令,具體的命令取決于不同的操作系統,注意不要調用Runtime.getRuntime().exec(String)接口,要用Runtime.getRuntime().exec(String[])這個接口,不然復雜命令的執行會有問題。例子如下(拿cpu個數,其他類似):

目前創新互聯已為上千家的企業提供了網站建設、域名、網頁空間、網站托管維護、企業網站設計、莫力達網站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協力一起成長,共同發展。

定義命令:

WindowsCmd ="cmd.exe /c echo %NUMBER_OF_PROCESSORS%";//windows的特殊

SolarisCmd = {"/bin/sh", "-c", "/usr/sbin/psrinfo | wc -l"};

AIXCmd = {"/bin/sh", "-c", "/usr/sbin/lsdev -Cc processor | wc -l"};

HPUXCmd = {"/bin/sh", "-c", "echo \"map\" | /usr/sbin/cstm | grep CPU | wc -l "};

LinuxCmd = {"/bin/sh", "-c", "cat /proc/cpuinfo | grep ^process | wc -l"};

然后判斷系統:

os = System.getProperty("os.name").toLowerCase();

根據不同的操作系統call不同的命令。

*/

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.LineNumberReader;

public class GetMACAddress

{

public String getMACAddress(String ipAddress)

{

String str = "",strMAC = "",macAddress = "";

try

{

Process pp = Runtime.getRuntime().exec("nbtstat -a " + ipAddress);

InputStreamReader ir = new InputStreamReader(pp.getInputStream());

LineNumberReader input = new LineNumberReader(ir);

for(int i = 1;i 100;i++)

{

str = input.readLine();

if(str != null)

{

if(str.indexOf("MAC Address") 1)

{

strMAC = str.substring(str.indexOf("MAC Address") + 14,str.length());

break;

}

}

}

}

catch(IOException ex)

{

return "Can't Get MAC Address!";

}

//

if(strMAC.length() 17)

{

return "Error!";

}

macAddress = strMAC.substring(0,2) + ":"

+ strMAC.substring(3,5) + ":"

+ strMAC.substring(6,8) + ":"

+ strMAC.substring(9,11) + ":"

+ strMAC.substring(12,14) + ":"

+ strMAC.substring(15,17);

//

return macAddress;

}

public static void main(String[] args)

{

GetMACAddress getMACAddress = new GetMACAddress();

System.out.println(getMACAddress.getMACAddress("172.18.8.225"));

try

{

java.lang.Process proc = Runtime.getRuntime().exec("ipconfig /all");

InputStream istr = proc.getInputStream();

byte[] data = new byte[1024];

istr.read(data);

String netdata = new String(data);

System.out.println("Your Mac Address=" + procAll(netdata));

}

catch(IOException e)

{

System.out.println("error=" + e);

}

}

public static String procAll(String str)

{

return procStringEnd(procFirstMac(procAddress(str)));

}

public static String procAddress(String str)

{

int indexof = str.indexOf("Physical Address");

if(indexof 0)

{

return str.substring(indexof,str.length());

}

return str;

}

public static String procFirstMac(String str)

{

int indexof = str.indexOf(":");

if(indexof 0)

{

return str.substring(indexof + 1,str.length()).trim();

}

return str;

}

public static String procStringEnd(String str)

{

int indexof = str.indexOf("\r");

if(indexof 0)

{

return str.substring(0,indexof).trim();

}

return str;

}

}

import java.util.Vector;

class GetNetMAC

{

//網卡物理地址長度

static private final int _physicalLength = 16;

public static void main(String[] args)

{

//output you computer phycail ip address

System.out.println("The MAC Addressis:\t" + getPhysicalAddress());

}

static public String getPhysicalAddress()

{

GetNetMACShell shell = new GetNetMACShell();

String cmd = "cmd.exe /c ipconfig/all";

Vector result;

result = shell.execute(cmd);

return parseCmd(result.toString());

}

//從字符串中解析出所需要獲得的字符串

static private String parseCmd(String s)

{

String find = "Physical Address. . . . . . . . . :";

int findIndex = s.indexOf(find);

if(findIndex == -1)

{

return "not find";

}

else

{

return s.substring(findIndex + find.length() + 1,findIndex + find.length() + 1 + _physicalLength);

}

}

}

import java.io.BufferedReader;

import java.io.DataInputStream;

import java.io.InputStreamReader;

import java.util.Vector;

public class GetNetMACShell

{

private Process process = null;

public Vector execute(String shellCommand)

{

try

{

Start(shellCommand);

Vector vResult = new Vector();

DataInputStream in = new DataInputStream(process.getInputStream());

BufferedReader reader = new BufferedReader(new InputStreamReader(in));

String line;

do

{

line = reader.readLine();

if(line == null)

{

break;

}

else

{

vResult.addElement(line);

}

}

while(true);

reader.close();

return vResult;

}

catch(Exception e)

{

//error

return null;

}

}

public void Start(String shellCommand)

{

try

{

if(process != null)

{

kill();

}

Runtime sys = Runtime.getRuntime();

process = sys.exec(shellCommand);

}

catch(Exception e)

{

System.out.println(e.toString());

}

}

public void kill()

{

if(process != null)

{

process.destroy();

process = null;

}

}

}

試試是否可以:)

怎樣用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);而調用有參數的方法時,則需要將參數在后面依次傳入,注意按順序噢:

用java獲得機器的唯一號

一、上Google搜一下Mac及CPU ID的C代碼

二、上java.sun.com找那個JNI的指南

三、你用二的方法把一的代碼給包一下。

其實利用在java中的runtime來執行在win里面的ipconfig -all的命令可以實現的!!

java.lang.Process proc = Runtime.getRuntime().exec("ipconfig /all");

InputStream istr = proc.getInputStream();

byte[] data = new byte[1024];

istr.read(data);

netdata = new String(data);

分析其中的netdata就是那!,有關cpu的可以類同實現!

java如何獲取遠程計算機的系統信息,cpu使用情況,磁盤使用情況等等

1、在遠程server里搭建一個http服務,并支持某種服務端語言(如.net或php之類)

2、用服務端語言獲取到服務器的磁盤信息,把結果輸出

3、在本地用JS寫一段AJAX腳本,遠程請求服務端寫好的程序,得到結果,并展示給用戶

html

head

title提取硬盤序列號/title

script

function disk() {//硬盤序列號 信息

 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

 var service = locator.ConnectServer(".");

 var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");

 var e = new Enumerator (properties);

 document.write("table border=1");

 for (;!e.atEnd();e.moveNext ())

 {

var p = e.item ();

document.write("tr");

document.write("td" + p.signature + "/td");

document.write("/tr");

 }

 document.write("/table");

}

/script

/head

body

input type="button" value="硬盤序列號" onclick="disk()"

/body

/html

在這上找的代碼:

對于寫過ASP或.net 的人來說,通過asp或.net 語言來獲得客戶端的硬件信息是很熟悉的.但如何通過javascript這種客戶端腳本來獲得客戶端的信息呢?請看以下實例:

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"

html

 head

titlejavascript獲得客戶端硬件信息-;/title

meta name="GENERATOR" content="Microsoft Visual Studio .NET

7.1"

meta name="vs_targetSchema"

content=""

 script id=clientEventHandlersJS language=javascript

!--

function Button2_onclick() {//CPU 信息

 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

 var service = locator.ConnectServer(".");

 var properties = service.ExecQuery("SELECT * FROM Win32_Processor");

 var e = new Enumerator (properties);

 document.write("table border=1");

 for (;!e.atEnd();e.moveNext ())

 {

var p = e.item ();

document.write("tr");

document.write("td" + p.Caption + "/td");

document.write("td" + p.DeviceID + "/td");

document.write("td" + p.Name + "/td");

document.write("td" + p.CpuStatus + "/td");

document.write("td" + p.Availability + "/td");

document.write("td" + p.Level + "/td");

document.write("td" + p.ProcessorID + "/td");

document.write("td" + p.SystemName + "/td");

document.write("td" + p.ProcessorType + "/td");

document.write("/tr");

 }

 document.write("/table");

}

function Button1_onclick() {//軟盤信息

 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

 var service = locator.ConnectServer(".");

 var properties = service.ExecQuery("SELECT * FROM Win32_FloppyDrive");

 var e = new Enumerator (properties);

 document.write("table border=1");

 for (;!e.atEnd();e.moveNext ())

 {

var p = e.item ();

document.write("tr");

document.write("td" + p.Description + "/td");

document.write("td" + p.DeviceID + "/td");

document.write("td" + p.Status + "/td");

document.write("td" + p.Manufacuturer + "/td");

document.write("/tr");

 }

 document.write("/table");

}

function Button1_onclick() {//CD-ROM 信息

 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

 var service = locator.ConnectServer(".");

 var properties = service.ExecQuery("SELECT * FROM Win32_CDROMDrive");

 var e = new Enumerator (properties);

 document.write("table border=1");

 for (;!e.atEnd();e.moveNext ())

 {

var p = e.item ();

document.write("tr");

document.write("td" + p.Caption + "/td");

document.write("td" + p.Description + "/td");

document.write("td" + p.Drive + "/td");

document.write("td" + p.Status + "/td");

document.write("td" + p.MediaLoaded + "/td");

document.write("/tr");

 }

 document.write("/table");

}

function Button1_onclick() {//鍵盤信息

 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

 var service = locator.ConnectServer(".");

 var properties = service.ExecQuery("SELECT * FROM Win32_Keyboard");

 var e = new Enumerator (properties);

 document.write("table border=1");

 for (;!e.atEnd();e.moveNext ())

 {

var p = e.item ();

document.write("tr");

document.write("td" + p.Description + "/td");

document.write("td" + p.Name + "/td");

document.write("td" + p.Status + "/td");

document.write("/tr");

 }

 document.write("/table");

}

function Button1_onclick() {//主板信息

 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

 var service = locator.ConnectServer(".");

 var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");

 var e = new Enumerator (properties);

 document.write("table border=1");

 for (;!e.atEnd();e.moveNext ())

 {

var p = e.item ();

document.write("tr");

document.write("td" + p.HostingBoard + "/td");

document.write("td" + p.Manufacturer + "/td");

document.write("td" + p.PoweredOn + "/td");

document.write("td" + p.Product + "/td");

document.write("td" + p.SerialNumber + "/td");

document.write("td" + p.Version + "/td");

document.write("/tr");

 }

 document.write("/table");

}

//--

/script

/head

 body

INPUT id="Button1" type="button" value="Button"

name="Button1" language=javascript onclick="return Button1_onclick()"

 /body

/html

使用javascript方式獲得客戶端的信息主要的優點是,不需求服務器資源.不需求刷新網頁.直接在客戶端執行腳本獲得顯示.

在這上找到了硬盤序列號的參數:

\'獲得硬盤序列號

Dim cmicWmi As New System.Management.ManagementObjectSearcher(\"SELECT * FROM Win32_DiskDrive\")

Dim Uint32 As UInt32

For Each cmicWmiObj As ManagementObject In cmicWmi.Get

Uint32 = cmicWmiObj(\"signature\")

Next

TextBox1.Text = Uint32.ToString

和在一塊總算給提出來了,呵呵。

java 怎么獲取硬盤序列號

public?static?void?main(String[]?args)?{

String?HDserialnumber?=?getHdSerialInfo();

System.out.println(HDserialnumber);

}

public?static?String?getHdSerialInfo()?{

String?line?=?"";

String?HdSerial?=?"";//?定義變量?硬盤序列號

try?{

Process?proces?=?Runtime.getRuntime().exec("cmd?/c?dir?c:");//?獲取命令行參數

BufferedReader?buffreader?=?new?BufferedReader(new?InputStreamReader(proces.getInputStream()));

while?((line?=?buffreader.readLine())?!=?null)?{

if?(line.indexOf("卷的序列號是?")?!=?-1)?{?//?讀取參數并獲取硬盤序列號

HdSerial?=?line.substring(line.indexOf("卷的序列號是?")?+?"卷的序列號是?".length(),?line.length());

break;

}

}

}?catch?(IOException?e)?{

e.printStackTrace();

}

return?HdSerial;//?返回硬盤序列號?卷的序列?非物理

}

當前標題:硬盤序列號java代碼 硬件編碼和硬盤序列號
鏈接URL:http://m.newbst.com/article48/dodhjep.html

成都網站建設公司_創新互聯,為您提供動態網站品牌網站設計電子商務網站建設域名注冊定制網站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

營銷型網站建設