中间件底层,websocket

Server.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Server.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "Server.h"
  5. #include "ServerDlg.h"
  6. // CServerApp
  7. // 2021-02-04 移动到对话框初始化函数中
  8. LONG WINAPI AppUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo)
  9. {
  10. RecordExceptionInfo(ExceptionInfo, "HttpServer");
  11. return EXCEPTION_EXECUTE_HANDLER;
  12. }
  13. BEGIN_MESSAGE_MAP(CServerApp, CWinApp)
  14. ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
  15. END_MESSAGE_MAP()
  16. // CServerApp construction
  17. CServerApp::CServerApp()
  18. {
  19. // TODO: add construction code here,
  20. // Place all significant initialization in InitInstance
  21. SetUnhandledExceptionFilter(AppUnhandledExceptionFilter);
  22. }
  23. // The one and only CServerApp object
  24. CServerApp theApp;
  25. // CServerApp initialization
  26. BOOL CServerApp::InitInstance()
  27. {
  28. // 禁止多个实例的同时运行
  29. HANDLE hMutexOneInstance = ::CreateMutex(NULL, TRUE, _T(AfxGetAppName()));
  30. if (::GetLastError() == ERROR_ALREADY_EXISTS)
  31. {
  32. if (hMutexOneInstance) // Release the mutex
  33. {
  34. ::ReleaseMutex(hMutexOneInstance);
  35. }
  36. HWND hWndPrevious = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
  37. while (::IsWindow(hWndPrevious))
  38. {
  39. // 检查窗口是否有预设的标记? 有,则是我们寻找的主窗口
  40. if (::GetProp(hWndPrevious, m_pszAppName))
  41. {
  42. // 主窗口已最小化,则恢复其大小
  43. if (::IsIconic(hWndPrevious)) ::ShowWindow(hWndPrevious, SW_RESTORE);
  44. ::SetForegroundWindow(hWndPrevious); // 将主窗激活
  45. ::SetForegroundWindow(::GetLastActivePopup(hWndPrevious)); // 将主窗的对话框激活
  46. return FALSE;
  47. } // end if
  48. hWndPrevious = ::GetWindow(hWndPrevious, GW_HWNDNEXT); // 继续寻找下一个窗口
  49. } // end while
  50. } // end if
  51. // InitCommonControlsEx() is required on Windows XP if an application
  52. // manifest specifies use of ComCtl32.dll version 6 or later to enable
  53. // visual styles. Otherwise, any window creation will fail.
  54. INITCOMMONCONTROLSEX InitCtrls;
  55. InitCtrls.dwSize = sizeof(InitCtrls);
  56. // Set this to include all the common control classes you want to use
  57. // in your application.
  58. InitCtrls.dwICC = ICC_WIN95_CLASSES;
  59. InitCommonControlsEx(&InitCtrls);
  60. CWinApp::InitInstance();
  61. AfxEnableControlContainer();
  62. // Create the shell manager, in case the dialog contains
  63. // any shell tree view or shell list view controls.
  64. CShellManager *pShellManager = new CShellManager;
  65. // Standard initialization
  66. // If you are not using these features and wish to reduce the size
  67. // of your final executable, you should remove from the following
  68. // the specific initialization routines you do not need
  69. // Change the registry key under which our settings are stored
  70. // TODO: You should modify this string to be something appropriate
  71. // such as the name of your company or organization
  72. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  73. CServerDlg dlg;
  74. m_pMainWnd = &dlg;
  75. INT_PTR nResponse = dlg.DoModal();
  76. if (nResponse == IDOK)
  77. {
  78. // TODO: Place code here to handle when the dialog is
  79. // dismissed with OK
  80. }
  81. else if (nResponse == IDCANCEL)
  82. {
  83. // TODO: Place code here to handle when the dialog is
  84. // dismissed with Cancel
  85. }
  86. // Delete the shell manager created above.
  87. if (pShellManager != NULL)
  88. {
  89. delete pShellManager;
  90. }
  91. // Since the dialog has been closed, return FALSE so that we exit the
  92. // application, rather than start the application's message pump.
  93. return FALSE;
  94. }