dllmain.cpp.in 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
  11. #define WIN32_LEAN_AND_MEAN
  12. #include <windows.h>
  13. #define OPENCV_MODULE_S "@the_module@"
  14. namespace cv {
  15. extern __declspec(dllimport) bool __termination; // Details: #12750
  16. }
  17. #ifdef _WIN32_WCE
  18. #define DLL_MAIN_ARG0 HANDLE
  19. #else
  20. #define DLL_MAIN_ARG0 HINSTANCE
  21. #endif
  22. extern "C"
  23. BOOL WINAPI DllMain(DLL_MAIN_ARG0, DWORD fdwReason, LPVOID lpReserved);
  24. extern "C"
  25. BOOL WINAPI DllMain(DLL_MAIN_ARG0, DWORD fdwReason, LPVOID lpReserved)
  26. {
  27. if (fdwReason == DLL_THREAD_DETACH || fdwReason == DLL_PROCESS_DETACH)
  28. {
  29. if (lpReserved != NULL) // called after ExitProcess() call
  30. {
  31. //printf("OpenCV: terminating: " OPENCV_MODULE_S "\n");
  32. cv::__termination = true;
  33. }
  34. }
  35. return TRUE;
  36. }