CmraViewer.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <tchar.h>
  5. #include <cxFormats.hpp>
  6. //---------------------------------------------------------------------------
  7. #include "AppGlobalF.h"
  8. #include "FrmVmsCmraViewerF.h"
  9. //---------------------------------------------------------------------------
  10. USEFORM("SRC\FRAME_VmsListF.cpp", FRAMEVmsList); /* TFrame: File Type */
  11. USEFORM("SRC\VMSVIEWMF.cpp", VMSVIEWM);
  12. USEFORM("LIB\ITSLog\FrmSqlErrorF.cpp", FrmSqlError);
  13. USEFORM("SRC\DMDbF.cpp", DMDb); /* TDataModule: File Type */
  14. USEFORM("SRC\FrmVmsCmraViewerF.cpp", FrmVmsCmraViewer);
  15. USEFORM("SRC\FrmCameraScreenF.cpp", FrmCameraScreen);
  16. USEFORM("SRC\FrmCameraInfoF.cpp", FrmCameraInfo);
  17. USEFORM("SRC\FrmCameraPlayerF.cpp", FrmCameraPlayer);
  18. USEFORM("SRC\FrmCameraFullScreenF.cpp", FrmCameraFullScreen);
  19. //---------------------------------------------------------------------------
  20. WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
  21. {
  22. #if 0
  23. if (!CheckApplicationParam()) {
  24. return 0;
  25. }
  26. if (!ApplicationSingleRun("TFrmVmsCmraViewer", "VMS 영상 모니터링")) {
  27. return 0;
  28. }
  29. #endif
  30. DateSeparator = '-';
  31. TimeSeparator = ':';
  32. ShortDateFormat ="yyyy-MM-dd";
  33. ShortTimeFormat = "hh:nn:ss";
  34. LongTimeFormat = "hh:nn:ss";
  35. cxFormatController()->BeginUpdate();
  36. cxFormatController()->UseDelphiDateTimeFormats = true;
  37. cxFormatController()->EndUpdate();
  38. cxFormatController()->GetFormats();
  39. cxFormatController()->NotifyListeners();
  40. String sLoginId = "ADMIN";
  41. bool bLogin = true;
  42. int nArgs = ParamCount();
  43. if (nArgs >= 1)
  44. {
  45. sLoginId = ParamStr(1);
  46. bLogin = false;
  47. }
  48. g_nPid = (int)GetCurrentProcessId();
  49. g_sAppDir = ExtractFilePath(Application->ExeName);
  50. g_sAppName = ChangeFileExt(ExtractFileName(Application->ExeName), "");
  51. g_sCfgDir = g_sAppDir + "Cfg\\";
  52. //g_sCfgDir = g_sAppDir + g_IniFileDir + "\\";
  53. g_sLangDir = g_sAppDir + "Lang\\";
  54. g_sLogDir = g_sAppDir + "Log\\";
  55. ForceDirectories(g_sLogDir.c_str());
  56. ChDir(g_sAppDir);
  57. /*
  58. * 시스템 운영환경을 ini 파일에서 읽어 온다.
  59. */
  60. LoadDefaultConfigInfo("ITS_OP");
  61. HANDLE hMutex;
  62. try
  63. {
  64. String sLockFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".lock");
  65. String sProgMutexNm = "HANTE_" + sLockFile;
  66. if ((hMutex=OpenMutex(MUTEX_ALL_ACCESS, false, sProgMutexNm.c_str()))==NULL)
  67. hMutex = CreateMutex(NULL, true, sProgMutexNm.c_str());
  68. else
  69. {
  70. if (g_sLang == "kr")
  71. {
  72. Application->MessageBox(L"영상뷰어 프로그램이 이미 실행중입니다.\r\n작업관리자의 프로세스 목록에서 프로그램을 종료후 실행해 주십시오.",
  73. L"프로그램 시작 오류!!!",
  74. MB_OK|MB_ICONERROR);
  75. }
  76. else
  77. {
  78. Application->MessageBox(L"The operating terminal program is already running.\r\nPlease exit the program from the process list of Task Manager and execute it.",
  79. L"Program Start Error!!!",
  80. MB_OK|MB_ICONERROR);
  81. }
  82. return 0;
  83. }
  84. }
  85. catch (Exception &exception)
  86. {
  87. Application->ShowException(&exception);
  88. return 0;
  89. }
  90. #if 0
  91. g_sLangDir = g_sLangDir + g_AppCfg.sLang + "\\";
  92. ForceDirectories(g_sLangDir.c_str());
  93. LangTrans = new TLangTrans("CctvCamViewer", g_AppCfg.sLang, g_sLangDir, true);
  94. #endif
  95. ITSLog = new TITSLog(g_sLogDir, g_sAppName, g_AppCfg.sLogDay);
  96. ITSLog->FLogCfg = g_LogCfg;
  97. try
  98. {
  99. ReportMemoryLeaksOnShutdown = true;
  100. Application->Initialize();
  101. Application->MainFormOnTaskBar = true;
  102. Application->Title = g_AppCfg.sTitle;
  103. Application->Title = "VMS 영상 모니터링";
  104. Application->CreateForm(__classid(TFrmVmsCmraViewer), &FrmVmsCmraViewer);
  105. Application->CreateForm(__classid(TDMDb), &DMDb);
  106. Application->Run();
  107. }
  108. catch (Exception &exception)
  109. {
  110. Application->ShowException(&exception);
  111. }
  112. catch (...)
  113. {
  114. try
  115. {
  116. throw Exception("");
  117. }
  118. catch (Exception &exception)
  119. {
  120. Application->ShowException(&exception);
  121. }
  122. }
  123. prog_exit:
  124. try
  125. {
  126. ReleaseMutex(hMutex);
  127. CloseHandle(hMutex);
  128. hMutex = NULL;
  129. }
  130. catch(...)
  131. {
  132. }
  133. return 0;
  134. }
  135. //---------------------------------------------------------------------------