kernel.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // kernel.cpp : Defines the initialization routines for the DLL.
  2. //
  3. #include "stdafx.h"
  4. #include <afxdllx.h>
  5. #include "kernel.h"
  6. #include "SocketHandle.h"
  7. //#include "database.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. AFX_EXTENSION_MODULE KernelDLL = { NULL, NULL };
  14. extern "C" int APIENTRY
  15. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  16. {
  17. // Remove this if you use lpReserved
  18. UNREFERENCED_PARAMETER(lpReserved);
  19. if (dwReason == DLL_PROCESS_ATTACH)
  20. {
  21. TRACE0("KERNEL.DLL Initializing!\n");
  22. // Extension DLL one-time initialization
  23. if (!AfxInitExtensionModule(KernelDLL, hInstance))
  24. return 0;
  25. // Insert this DLL into the resource chain
  26. // NOTE: If this Extension DLL is being implicitly linked to by
  27. // an MFC Regular DLL (such as an ActiveX Control)
  28. // instead of an MFC application, then you will want to
  29. // remove this line from DllMain and put it in a separate
  30. // function exported from this Extension DLL. The Regular DLL
  31. // that uses this Extension DLL should then explicitly call that
  32. // function to initialize this Extension DLL. Otherwise,
  33. // the CDynLinkLibrary object will not be attached to the
  34. // Regular DLL's resource chain, and serious problems will
  35. // result.
  36. new CDynLinkLibrary(KernelDLL);
  37. }
  38. else if (dwReason == DLL_PROCESS_DETACH)
  39. {
  40. TRACE0("KERNEL.DLL Terminating!\n");
  41. // Terminate the library before destructors are called
  42. AfxTermExtensionModule(KernelDLL);
  43. }
  44. OleInitialize(NULL);
  45. return 1; // ok
  46. }
  47. CDevicesManager* pDevicesManager = NULL;
  48. CVariantsManager* pVariantsManager = NULL;
  49. CEventServer* pEventServer = NULL;
  50. void CreateSystem(void)
  51. {
  52. if (pVariantsManager == NULL)
  53. {
  54. pVariantsManager = new CVariantsManager;
  55. }
  56. CSocketHandle::InitLibrary( MAKEWORD(2,2) );
  57. }
  58. void DestroySystem(void)
  59. {
  60. if (pVariantsManager != NULL)
  61. {
  62. delete pVariantsManager;
  63. }
  64. CSocketHandle::ReleaseLibrary();
  65. }