Created
June 18, 2010 14:42
-
-
Save alexmchale/443724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Enumeration; | |
import com.jacob.activeX.ActiveXComponent; | |
import com.jacob.com.ComThread; | |
import com.jacob.com.EnumVariant; | |
import com.jacob.com.Variant; | |
// http://stackoverflow.com/questions/1986732/how-to-get-a-unique-computer-identifier-in-java-like-disk-id-or-motherboard-id | |
public class Test { | |
public static void main(String[] args) { | |
ComThread.InitMTA(); | |
try { | |
ActiveXComponent wmi = new ActiveXComponent("winmgmts:\\\\."); | |
Variant instances = wmi.invoke("InstancesOf", "Win32_BaseBoard"); | |
Enumeration<Variant> en = new EnumVariant(instances.getDispatch()); | |
while (en.hasMoreElements()) | |
{ | |
ActiveXComponent bb = new ActiveXComponent(en.nextElement().getDispatch()); | |
System.out.println(bb.getPropertyAsString("SerialNumber")); | |
break; | |
} | |
} finally { | |
ComThread.Release(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment