-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetDeviceInfo.cs
82 lines (72 loc) · 2.52 KB
/
GetDeviceInfo.cs
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
using System;
using System.Management;
using System.Text;
namespace LoginPage
{
public class GetDeviceInfo
{
//Device Information Variables
private string mBB, proserial, hdserial;
private Byte[] OBKData = new Byte[30];
private Byte[] CBKData = new Byte[30];
public GetDeviceInfo()
{
mBB = getMotherBoardSerial();
proserial = getProcessorID();
hdserial = getHardDiskID();
}
//Get device information
public string DeviceInfo()
{
Byte[] MBB_Buffer = Encoding.ASCII.GetBytes(mBB);
Byte[] Proc_Buffer = Encoding.ASCII.GetBytes(proserial);
Byte[] HDD_Buffer = Encoding.ASCII.GetBytes(hdserial);
for (int i = 0; i < 10; i++)
OBKData[i] = MBB_Buffer[i];
for (int i = 10, j = 0; i < 20; i++, j++)
OBKData[i] = Proc_Buffer[j];
for (int i = 20, j = 0; i < 30; i++, j++)
OBKData[i] = HDD_Buffer[j];
for (int i = 0; i < 30; i++)
{
int temp1 = (int)OBKData[i] + 7;
CBKData[i] = (Byte)temp1;
}
var str = System.Text.Encoding.Default.GetString(CBKData);
return str;
}
private string getMotherBoardSerial()
{
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
ManagementObjectCollection moc = mos.Get();
string motherBoard = "";
foreach (ManagementObject mo in moc)
{
motherBoard = (string)mo["SerialNumber"];
}
return motherBoard;
}
private string getProcessorID()
{
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
ManagementObjectCollection mbsList = mbs.Get();
string id = "";
foreach (ManagementObject mo in mbsList)
{
id = mo["ProcessorID"].ToString();
}
return id;
}
private string getHardDiskID()
{
string hddID = null;
ManagementClass mc = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject strt in moc)
{
hddID += Convert.ToString(strt["VolumeSerialNumber"]);
}
return hddID.Trim().ToString();
}
}
}