dllmain.cpp.in 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef _WIN32
  5. #error "Build configuration error"
  6. #endif
  7. #ifndef CVAPI_EXPORTS
  8. #error "Build configuration error"
  9. #endif
  10. #define WIN32_LEAN_AND_MEAN
  11. #include <windows.h>
  12. #define OPENCV_MODULE_S "@the_module@"
  13. namespace cv {
  14. extern __declspec(dllimport) bool __termination; // Details: #12750
  15. }
  16. #ifdef _WIN32_WCE
  17. #define DLL_MAIN_ARG0 HANDLE
  18. #else
  19. #define DLL_MAIN_ARG0 HINSTANCE
  20. #endif
  21. extern "C"
  22. BOOL WINAPI DllMain(DLL_MAIN_ARG0, DWORD fdwReason, LPVOID lpReserved);
  23. extern "C"
  24. BOOL WINAPI DllMain(DLL_MAIN_ARG0, DWORD fdwReason, LPVOID lpReserved)
  25. {
  26. if (fdwReason == DLL_THREAD_DETACH || fdwReason == DLL_PROCESS_DETACH)
  27. {
  28. if (lpReserved != NULL) // called after ExitProcess() call
  29. {
  30. //printf("OpenCV: terminating: " OPENCV_MODULE_S "\n");
  31. cv::__termination = true;
  32. }
  33. }
  34. return TRUE;
  35. }