FrmMainF.cpp.~47~ 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "EncryptionF.h"
  4. #pragma hdrstop
  5. #include "FrmMainF.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "cxContainer"
  9. #pragma link "cxControls"
  10. #pragma link "cxEdit"
  11. #pragma link "cxGraphics"
  12. #pragma link "cxLookAndFeelPainters"
  13. #pragma link "cxLookAndFeels"
  14. #pragma link "cxMaskEdit"
  15. #pragma link "cxSpinEdit"
  16. #pragma link "cxTextEdit"
  17. #pragma link "dxSkinBlack"
  18. #pragma link "dxSkinMcSkin"
  19. #pragma link "dxSkinsCore"
  20. #pragma link "cxButtons"
  21. #pragma link "cxDropDownEdit"
  22. #pragma resource "*.dfm"
  23. TFrmMain *FrmMain;
  24. //---------------------------------------------------------------------------
  25. __fastcall TFrmMain::TFrmMain(TComponent* Owner)
  26. : TForm(Owner)
  27. {
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TFrmMain::cboLicenseTypePropertiesChange(TObject *Sender)
  31. {
  32. bool isVisible = false;
  33. if (cboLicenseType->ItemIndex == 0) {
  34. isVisible = true;
  35. }
  36. seDemoDuration->Enabled = isVisible;
  37. }
  38. //---------------------------------------------------------------------------
  39. #if 0
  40. #include <iostream>
  41. #include <string>
  42. std::string GetCpuUUID()
  43. {
  44. TGUID guid;
  45. guid = CreateGUID();
  46. std::wstring uuid = System::Sysutils::GUIDToString(guid).c_bstr();
  47. return std::string(uuid.begin(), uuid.end());
  48. }
  49. #endif
  50. //---------------------------------------------------------------------------
  51. void __fastcall TFrmMain::btnHostNameClick(TObject *Sender)
  52. {
  53. char szNom[512];
  54. DWORD size = 512;
  55. GetComputerName(szNom, &size);
  56. txtHostName->Text = String(szNom);
  57. }
  58. //---------------------------------------------------------------------------
  59. void __fastcall TFrmMain::btnLicenseGenerateXmlClick(TObject *Sender)
  60. {
  61. moLicenseXml->Lines->Clear();
  62. GUID guid;
  63. CoCreateGuid(&guid);
  64. //UUID uuid;
  65. //UuidCreateSequential(&uuid);
  66. String product = "AIP Gateway";
  67. String serialId = GUIDToString(guid);
  68. serialId = StringReplace(serialId, "{", "", TReplaceFlags() << rfReplaceAll);
  69. serialId = StringReplace(serialId, "}", "", TReplaceFlags() << rfReplaceAll);
  70. String issueDay = Now().FormatString("YYYY-MM-DD");
  71. String licensee = txtHostName->Text.Trim();
  72. String edition = cboProductType->ItemIndex == 0 ? "standard" : "enterprise";
  73. String type = cboLicenseType->ItemIndex == 0 ? "demo" : "product";
  74. String accounts = String((int)seLicenseCnt->Value);
  75. String identifiedHost = txtHostName->Text.Trim();
  76. AnsiString encKey = product.UpperCase() + "hanteinfo12#$!" + serialId.LowerCase() + issueDay + edition.UpperCase() + type.LowerCase() + AnsiString((int)seLicenseCnt->Value + 10000) + identifiedHost.LowerCase();
  77. String signature = ITSSHA256_Encrpyt(encKey);;
  78. String demoDuration = String((int)seDemoDuration->Value);
  79. moLicenseXml->Lines->Add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  80. moLicenseXml->Lines->Add("<aip_license>");
  81. moLicenseXml->Lines->Add(" <license version=\"1.0\">");
  82. moLicenseXml->Lines->Add(" <product version=\"2\">" + product + "</product>");
  83. moLicenseXml->Lines->Add(" <serialId>" + serialId + "</serialId>");
  84. moLicenseXml->Lines->Add(" <issueDay>" + issueDay + "</issueDay>");
  85. //moLicenseXml->Lines->Add(" <licensee>" + licensee + "</licensee>");
  86. moLicenseXml->Lines->Add(" <edition>" + edition + "</edition>");
  87. moLicenseXml->Lines->Add(" <type>" + type + "</type>");
  88. moLicenseXml->Lines->Add(" <accounts>" + accounts + "</accounts>");
  89. moLicenseXml->Lines->Add(" <identifiedHost>" + identifiedHost + "</identifiedHost>");
  90. moLicenseXml->Lines->Add(" <signature>" + signature + "</signature>");
  91. if (type == "demo") {
  92. moLicenseXml->Lines->Add(" <demoDuration>" + demoDuration + "</demoDuration>");
  93. }
  94. moLicenseXml->Lines->Add(" </license>");
  95. moLicenseXml->Lines->Add("</aip_license>");
  96. moLicenseXml->Lines->Add("");
  97. }
  98. //---------------------------------------------------------------------------