public ArrayList GetDriveInfo() { foreach (ManagementObject wmi_HD in searcher.Get()) { hd.Model = wmi_HD["Model"].ToString(); hd.Type = wmi_HD["InterfaceType"].ToString(); hdCollection.Add(hd); } searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); foreach (ManagementObject wmi_HD in searcher.Get()) { hd = (HardDrive)hdCollection[i]; // get the hardware serial no. if (wmi_HD["SerialNumber"] == null) hd.SerialNo = "None"; else hd.SerialNo = wmi_HD["SerialNumber"].ToString(); ++i; } return hdCollection; }
/// <summary> /// Buraya mac in dışındaki parametreleri de hesabı cem ederek değiştirilecek /// </summary> /// <returns></returns> private bool CheckLicense() { RegistryKey check = Registry.LocalMachine.OpenSubKey("Software\\ManadgementApps"); try { LCryp lc = new LCryp(); HardDrive hd = new HardDrive(); HardDDInfo hi = new HardDDInfo(); string data = String.Empty; string compE = lc.Decrypt(check.GetValue("EKey").ToString()); string comp = check.GetValue("LKey").ToString(); if (comp.Trim() == compE.Trim()) { try { ArrayList hdCollection = new ArrayList(); hdCollection = hi.GetDriveInfo(); if (hdCollection.Count == 1) { foreach (HardDrive item in hdCollection) { hd.SerialNo = item.SerialNo; hd.Model = item.Model; hd.Type = item.Type; } } else { MessageBox.Show("Please Use Only One HDD"); Application.Exit(); } data.Trim(); data = hd.SerialNo.ToUpper(); //data = data.Substring(0, 30); if (compE == data) return true; else return false; } catch { return false; } } else return false; } catch { return false; } }
public HardDDInfo() { hdCollection = new ArrayList(); searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); hd = new HardDrive(); }
private string GenerateSerial() { string data = String.Empty; try { foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) { if (item.GetPhysicalAddress().ToString() != "") { data = item.GetPhysicalAddress().ToString(); } } HardDDInfo hi = new HardDDInfo(); HardDrive hd = new HardDrive(); ArrayList hdCollection = new ArrayList(); hdCollection = hi.GetDriveInfo(); if (hdCollection.Count == 1) { foreach (HardDrive item in hdCollection) { hd.SerialNo = item.SerialNo; hd.Model = item.Model; hd.Type = item.Type; } } //MessageBox.Show(String.Format("Type : {0}\nModel : {1}\nSerial{2}",hd.Type,hd.Model,hd.SerialNo)); data.Trim(); data = hd.SerialNo.ToUpper(); //data = data.Substring(0, 30); //for (int i = 0; i < data.Length; i++) //{ // if (i%5 == 0 && i!= 0) // { // data = data.Insert(i, " - "); // i = i + 1; // } //} return data; } catch (Exception) { return String.Empty; } }