诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
1.7 KiB

  1. // dllmain.cpp : 定义 DLL 的初始化例程。
  2. //
  3. #include "stdafx.h"
  4. #include <afxwin.h>
  5. #include <afxdllx.h>
  6. //组件头文件
  7. #include <WinSock2.h>
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #endif
  11. static AFX_EXTENSION_MODULE KernelEngineDLL = { NULL, NULL };
  12. extern "C" int APIENTRY
  13. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  14. {
  15. // 如果使用 lpReserved,请将此移除
  16. UNREFERENCED_PARAMETER(lpReserved);
  17. if (dwReason == DLL_PROCESS_ATTACH)
  18. {
  19. TRACE0("KernelEngine.DLL 正在初始化!\n");
  20. // 扩展 DLL 一次性初始化
  21. if (!AfxInitExtensionModule(KernelEngineDLL, hInstance))
  22. return 0;
  23. // 将此 DLL 插入到资源链中
  24. // 注意: 如果此扩展 DLL 由
  25. // MFC 规则 DLL (如 ActiveX 控件)隐式链接到,
  26. // 而不是由 MFC 应用程序链接到,则需要
  27. // 将此行从 DllMain 中移除并将其放置在一个
  28. // 从此扩展 DLL 导出的单独的函数中。 使用此扩展 DLL 的
  29. // 规则 DLL 然后应显式
  30. // 调用该函数以初始化此扩展 DLL。 否则,
  31. // CDynLinkLibrary 对象不会附加到
  32. // 规则 DLL 的资源链,并将导致严重的
  33. // 问题。
  34. new CDynLinkLibrary(KernelEngineDLL);
  35. //初始化 COM
  36. CoInitialize(NULL);
  37. //初始化 SOCKET
  38. WSADATA WSAData;
  39. WORD wVersionRequested = MAKEWORD(2, 2);
  40. int iErrorCode = WSAStartup(wVersionRequested, &WSAData);
  41. if (iErrorCode != 0) return 0;
  42. }
  43. else if (dwReason == DLL_PROCESS_DETACH)
  44. {
  45. TRACE0("KernelEngine.DLL 正在终止!\n");
  46. CoUninitialize();
  47. // 在调用析构函数之前终止该库
  48. AfxTermExtensionModule(KernelEngineDLL);
  49. }
  50. return 1; // 确定
  51. }