package zhuce; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.text.SimpleDateFormat; import java.util.Date; public class RegisterMark { public static String getRegister(String s) { String s1="",s2=""; SimpleDateFormat sd=new SimpleDateFormat("yyyy"); Date d=new Date(); s+=sd.format(d); for(int i=0;i -1) { // Windows²Ù×÷ϵͳµÄcmd.exeµÄ¾ø¶Ô·¾¶ systemPath.append("c:/WINDOWS/system32/cmd.exe"); } if (system_name.indexOf("NT") > -1) { // NT²Ù×÷ϵͳµÄcmd.exeµÄ¾ø¶Ô·¾¶ systemPath.append("c:/WINDOWS/command.com"); } // Process pro = null; try { // Serial Number µÄµÃµ½ // ´ËÓï¾äÏ൱ÓÚÔÚcmdÏÂÃæÖ´ÐÐ dirµÄÃüÁî.²¢µÃµ½ÃüÁîÖ´ÐÐÍê±ÏºóµÄÊä³öÁ÷ pro = Runtime.getRuntime().exec(systemPath.toString() + " /c dir"); InputStream input = pro.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(input)); // ¶ÁÈ¡µÚÒ»ÐÐ String message = br.readLine(); // Serial Number µÄÁãʱ±äÁ¿ @SuppressWarnings("unused") String serNuResult = null; int index = -1; // ¶ÁÈ¡ÏÂÒ»ÐÐ message = br.readLine(); // MacµØÖ·µÄµÃµ½ // ´ËÓï¾äÏ൱ÓÚÔÚcmdÏÂÃæÖ´ÐÐ ipconfig/all µÄÃüÁî.²¢µÃµ½ÃüÁîÖ´ÐÐÍê±ÏºóµÄÊä³öÁ÷ pro = Runtime.getRuntime().exec(systemPath.toString() + " /c ipconfig/all"); input= pro.getInputStream(); br = new BufferedReader(new InputStreamReader(input)); // ¶ÁÈ¡µÚÒ»ÐÐ // message = br.readLine(); // MacµØÖ· µÄÁãʱ±äÁ¿ while (message != null) { if ((index = message.indexOf("Physical Address")) > 0) { macResult = message.substring(index + 36).trim(); break; } // ¶ÁÈ¡ÏÂÒ»ÐÐ message = br.readLine(); } }catch(Exception e){ e.printStackTrace(); } return macResult; } }