FrmMainF.cpp.~46~ 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. String GetCpuUUID()
  40. {
  41. try
  42. {
  43. // WMI를 사용하여 컴퓨터의 고유 식별자 가져오기
  44. TVarRec args[1];
  45. args[0] = Variant(L"UUID");
  46. Variant result = ExecCmdProcess(L"wmic", L"csproduct get %s", args, 1);
  47. ShowMessage(L"유일한 식별자 (UUID): " + result);
  48. }
  49. catch (Exception &exception)
  50. {
  51. Application->ShowException(&exception);
  52. }
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TFrmMain::btnHostNameClick(TObject *Sender)
  56. {
  57. char szNom[512];
  58. DWORD size = 512;
  59. GetComputerName(szNom, &size);
  60. txtHostName->Text = String(szNom);
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TFrmMain::btnLicenseGenerateXmlClick(TObject *Sender)
  64. {
  65. moLicenseXml->Lines->Clear();
  66. GUID guid;
  67. CoCreateGuid(&guid);
  68. //UUID uuid;
  69. //UuidCreateSequential(&uuid);
  70. String product = "AIP Gateway";
  71. String serialId = GUIDToString(guid);
  72. serialId = StringReplace(serialId, "{", "", TReplaceFlags() << rfReplaceAll);
  73. serialId = StringReplace(serialId, "}", "", TReplaceFlags() << rfReplaceAll);
  74. String issueDay = Now().FormatString("YYYY-MM-DD");
  75. String licensee = txtHostName->Text.Trim();
  76. String edition = cboProductType->ItemIndex == 0 ? "standard" : "enterprise";
  77. String type = cboLicenseType->ItemIndex == 0 ? "demo" : "product";
  78. String accounts = String((int)seLicenseCnt->Value);
  79. String identifiedHost = txtHostName->Text.Trim();
  80. AnsiString encKey = product.UpperCase() + "hanteinfo12#$!" + serialId.LowerCase() + issueDay + edition.UpperCase() + type.LowerCase() + AnsiString((int)seLicenseCnt->Value + 10000) + identifiedHost.LowerCase();
  81. String signature = ITSSHA256_Encrpyt(encKey);;
  82. String demoDuration = String((int)seDemoDuration->Value);
  83. moLicenseXml->Lines->Add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  84. moLicenseXml->Lines->Add("<aip_license>");
  85. moLicenseXml->Lines->Add(" <license version=\"1.0\">");
  86. moLicenseXml->Lines->Add(" <product version=\"2\">" + product + "</product>");
  87. moLicenseXml->Lines->Add(" <serialId>" + serialId + "</serialId>");
  88. moLicenseXml->Lines->Add(" <issueDay>" + issueDay + "</issueDay>");
  89. //moLicenseXml->Lines->Add(" <licensee>" + licensee + "</licensee>");
  90. moLicenseXml->Lines->Add(" <edition>" + edition + "</edition>");
  91. moLicenseXml->Lines->Add(" <type>" + type + "</type>");
  92. moLicenseXml->Lines->Add(" <accounts>" + accounts + "</accounts>");
  93. moLicenseXml->Lines->Add(" <identifiedHost>" + identifiedHost + "</identifiedHost>");
  94. moLicenseXml->Lines->Add(" <signature>" + signature + "</signature>");
  95. if (type == "demo") {
  96. moLicenseXml->Lines->Add(" <demoDuration>" + demoDuration + "</demoDuration>");
  97. }
  98. moLicenseXml->Lines->Add(" </license>");
  99. moLicenseXml->Lines->Add("</aip_license>");
  100. moLicenseXml->Lines->Add("");
  101. }
  102. //---------------------------------------------------------------------------