Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

117 righe
3.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Management;
  5. using System.Net.Http;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Quanjiang.DigitalScholl.WebLicense
  9. {
  10. public class LicenseManager
  11. {
  12. public static bool GetNowTime(string lcdate)
  13. {
  14. bool islc = false;
  15. try
  16. {
  17. HttpClient client = new HttpClient();
  18. var data = client.GetStringAsync("http://cgi.im.qq.com/cgi-bin/cgi_svrtime").Result;
  19. if (!string.IsNullOrEmpty(data))
  20. {
  21. var dt = DateTime.Parse(data);
  22. islc = dt < DateTime.Parse(lcdate);
  23. }
  24. return islc;
  25. }
  26. catch
  27. {
  28. if (DateTime.Now >= DateTime.Parse(lcdate))
  29. {
  30. return false;
  31. }
  32. return true;
  33. }
  34. }
  35. public static string GetCPUSerialNumber()
  36. {
  37. try
  38. {
  39. string cpuSerialNumber = string.Empty;
  40. ManagementClass mc = new ManagementClass("Win32_Processor");
  41. ManagementObjectCollection moc = mc.GetInstances();
  42. foreach (ManagementObject mo in moc)
  43. {
  44. cpuSerialNumber = mo["ProcessorId"].ToString();
  45. break;
  46. }
  47. mc.Dispose();
  48. moc.Dispose();
  49. return cpuSerialNumber;
  50. }
  51. catch (Exception e)
  52. {
  53. return "bjqjcpuid";
  54. }
  55. }
  56. public static string GetHardDriverNumber()
  57. {
  58. try
  59. {
  60. ManagementClass mc = new ManagementClass("Win32_PhysicalMedia");
  61. ManagementObjectCollection moc = mc.GetInstances();
  62. string strID = string.Empty;
  63. foreach (ManagementObject mo in moc)
  64. {
  65. strID = mo.Properties["SerialNumber"].Value.ToString();
  66. break;
  67. }
  68. mc.Dispose();
  69. moc.Dispose();
  70. return strID;
  71. }
  72. catch (Exception e)
  73. {
  74. return "bjqjharddriverid";
  75. }
  76. }
  77. public static string GetBoisNumber()
  78. {
  79. try
  80. {
  81. ManagementClass mc = new ManagementClass("Win32_BIOS");
  82. ManagementObjectCollection moc = mc.GetInstances();
  83. string strID = string.Empty;
  84. foreach (ManagementObject mo in moc)
  85. {
  86. strID = mo.Properties["SerialNumber"].Value.ToString();
  87. break;
  88. }
  89. mc.Dispose();
  90. moc.Dispose();
  91. return strID;
  92. }
  93. catch (Exception e)
  94. {
  95. return "bjqjbiosid";
  96. }
  97. }
  98. public static string GetMachineName()
  99. {
  100. try
  101. {
  102. return System.Environment.MachineName;
  103. }
  104. catch (Exception e)
  105. {
  106. return "unknowmachine";
  107. }
  108. }
  109. }
  110. }