opEnv.cpp 665 B

1234567891011121314151617181920212223242526272829303132333435
  1. //#include "stdafx.h"
  2. #include <tchar.h>
  3. #include "opEnv.h"
  4. #include <windows.h>
  5. void* opEnv::m_instance = nullptr;
  6. TString opEnv::m_basePath;
  7. TString opEnv::m_opName;
  8. int opEnv::m_showErrorMsg = 1;
  9. void opEnv::setInstance(void* instance)
  10. {
  11. m_instance = instance;
  12. TCHAR buff[512] = {};
  13. ::GetModuleFileName(static_cast<HINSTANCE>(m_instance), buff, 512);
  14. TString s(buff);
  15. size_t index = s.rfind(_T("\\"));
  16. if (index != s.npos) {
  17. m_basePath = s.substr(0, index);
  18. m_opName = s.substr(index + 1);
  19. }
  20. }
  21. void* opEnv::getInstance()
  22. {
  23. return m_instance;
  24. }
  25. TString opEnv::getBasePath()
  26. {
  27. return m_basePath;
  28. }
  29. TString opEnv::getOpName() {
  30. return m_opName;
  31. }