zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package zhuce;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Vector;
import DataBase.DatabaseManagement;
import PbuliClass.ShowMessage;
import tbDataModel.Tb_Mac;
public class GetCpu {
    static String mac="δ»ñÈ¡µ½É豸»úÆ÷Âë";//»úÆ÷Âë
    static Scanner sc;
    static String property;
    static Vector<Tb_Mac> macs;
 
 
    /**»ñÈ¡CPUÐòÁкÅ*/
    public static String get_mac() {
        try {   
            Process process = Runtime.getRuntime().exec(  
                    new String[] { "wmic", "cpu", "get", "ProcessorId" });  
            process.getOutputStream().close();  
            sc = new Scanner(process.getInputStream()); 
            if(sc.hasNext()) {
                property = sc.next();   
                mac=sc.next()+getSerialNumber("c");    
            }
        } catch (IOException e) {  
            ShowMessage.zidingyi("»ñÈ¡»úÆ÷Âë³ö´í"+mac); 
        }
        return mac;  
    }
 
 
 
 
    /**»ñȡӲÅÌÐòÁкÅ*/
    public static String getSerialNumber(String drive) {
        String result = "";
        try {
            File file = File.createTempFile("realhowto",".vbs");
            file.deleteOnExit();
            FileWriter fw = new FileWriter(file);
 
            String vbs = "Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
                    +"Set colDrives = objFSO.Drives\n"
                    +"Set objDrive = colDrives.item(\"" + drive + "\")\n"
                    +"Wscript.Echo objDrive.SerialNumber";
            fw.write(vbs);
            fw.close();
            Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
            BufferedReader input =
                    new BufferedReader
                    (new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = input.readLine()) != null) {
                result += line;
            }
            input.close();
        }
        catch(Exception e){
            e.printStackTrace();
        }
        return result.trim();
    }
 
    /**ÏòÊý¾Ý¿âдÈë»úÆ÷Âë*/    
    public static void insert_database_mac() {
        int id=1;
        String update="UPDATE tb_mac SET mac='"+get_mac()+"' where id='"+id+"'";
        DatabaseManagement.update(update);// ¸üÐÂÊý¾Ý¿â        
    }
 
    /**ÏòÊý¾Ý¿âдÈë×¢²áÂë*/    
    public static void insert_passmac(String passmac) {
        int id=1;
        String update="UPDATE tb_mac SET passmac='"+passmac+"' where id='"+id+"'";
        DatabaseManagement.update(update);// ¸üÐÂÊý¾Ý¿â        
    }
 
    /**ÏòÊý¾Ý¿âдÈë»úÆ÷ÂëºÍ×¢²áÂë*/
    public static void write_p_m(String mac,String pass,String useday) {
        String[] ziduan= {"passmac","mac","useday","id"};
        String[] zhi= {pass,mac,useday,"1"};        
        DatabaseManagement.fast_alert_dbase("tb_mac", ziduan, zhi);
    }
 
    /**ÏòÊý¾Ý¿âдÈë×¢²áÂë»òÕßÊÔÓÃÌìÊý*/
    public static void write_p_m(String pass,String useday) {
        String[] ziduan= {"passmac","useday","id"};
        String[] zhi= {pass,useday,"1"};        
        DatabaseManagement.fast_alert_dbase("tb_mac", ziduan, zhi);
    }
 
 
 
}