CctvCmraViewer.cpp 4.5 KB

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