Reputation: 233
Is there any code in vb.net or java to get ID of computer >>?? I want to write a program which could get id of computer in order to make a license of software like microsoft did ?
Thanks in advance
Makara
Upvotes: 3
Views: 1373
Reputation: 21
You can use this function, it will return the mac address:
public String macname() throws IOException {
String mac = "null";
String[] getmac = new String[] { "cmd", "/c", "getmac /NH" };
Process pnew = Runtime.getRuntime().exec(getmac);
BufferedReader newin = new BufferedReader(new InputStreamReader(
pnew.getInputStream()));
String line1 = "";
String ab = "";
while ((line1 = newin.readLine()) != null) {
ab = ab + line1;
}
int in = ab.indexOf(' ');
mac = ab.substring(0, in);
return mac;
}
Upvotes: 2
Reputation: 88064
First off, microsoft licensing doesn't work this way.
They have a key which is generated on their side of things. When they sell you a copy of the software, they give you a key. Once you enter the key, the software sends some encrypted tcp packets back to MS in order to identify that the key is now in use and increase the usage count. It then creates a nicely hidden file on your system which contains the authorization for that key.
None of this involves getting the "id of computer".
Now, MS (under at least one of their licensing models) does take a snapshot of the system which includes the processor type, hard drive, and motherboard make/model in order to identify whether components have changed enough to trigger a potential check on whether the computer license needs to be reverified.
Which leaves us back to the idea that there isn't a single "ID" in a computer system. The last time it was attempted was by Intel with (I believe?) their PII processors. However, the public backlash was enough that they stopped putting serial numbers on the chip.
The next closest thing you can do is try and read a MAC address; but network cards change often enough that this is littered with pitfalls.
I would highly recommend you research other mechanisms for doing licensing keys if that's really what you want.
Upvotes: 7