Server.cpp
Upload User: whzytd4
Upload Date: 2022-08-01
Package Size: 7346k
Code Size: 2k
Category:

WinSock-NDIS

Development Platform:

Visual C++

  1. // Server.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "Server.h"
  5. #include "ServerDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CServerApp
  13. BEGIN_MESSAGE_MAP(CServerApp, CWinApp)
  14. //{{AFX_MSG_MAP(CServerApp)
  15. // NOTE - the ClassWizard will add and remove mapping macros here.
  16. //    DO NOT EDIT what you see in these blocks of generated code!
  17. //}}AFX_MSG
  18. ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  19. END_MESSAGE_MAP()
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CServerApp construction
  22. CServerApp::CServerApp()
  23. {
  24. // TODO: add construction code here,
  25. // Place all significant initialization in InitInstance
  26. }
  27. /////////////////////////////////////////////////////////////////////////////
  28. // The one and only CServerApp object
  29. CServerApp theApp;
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CServerApp initialization
  32. BOOL CServerApp::InitInstance()
  33. {
  34. if (!AfxSocketInit())
  35. {
  36. AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  37. return FALSE;
  38. }
  39. AfxEnableControlContainer();
  40. // Standard initialization
  41. // If you are not using these features and wish to reduce the size
  42. //  of your final executable, you should remove from the following
  43. //  the specific initialization routines you do not need.
  44. #ifdef _AFXDLL
  45. Enable3dControls(); // Call this when using MFC in a shared DLL
  46. #else
  47. Enable3dControlsStatic(); // Call this when linking to MFC statically
  48. #endif
  49. CServerDlg dlg;
  50. if (!dlg.StartService())
  51. {
  52. AfxMessageBox(_T("启动服务器失败!"),MB_OK, -1);
  53. return FALSE;
  54. }
  55. m_pMainWnd = &dlg;
  56. int nResponse = dlg.DoModal();
  57. if (nResponse == IDOK)
  58. {
  59. // TODO: Place code here to handle when the dialog is
  60. //  dismissed with OK
  61. }
  62. else if (nResponse == IDCANCEL)
  63. {
  64. // TODO: Place code here to handle when the dialog is
  65. //  dismissed with Cancel
  66. }
  67. // Since the dialog has been closed, return FALSE so that we exit the
  68. //  application, rather than start the application's message pump.
  69. return FALSE;
  70. }