AuotTestLoader.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "stdafx.h"
  2. #include "AuotTestLoader.h"
  3. #include "IAutoTestServer.h"
  4. using namespace DIOS::Dev::Detail::MachineryECOM;
  5. #ifdef _WIN64
  6. #ifdef _DEBUG
  7. const string AutotestFile = "AutoTest.dll";
  8. #else
  9. const string AutotestFile = "AutoTest.dll";
  10. #endif
  11. #else
  12. #ifdef _DEBUG
  13. const string AutotestFile = "AutoTest.dll";
  14. #else
  15. const string AutotestFile = "AutoTest.dll";
  16. #endif
  17. #endif
  18. AuotTestLoader *AuotTestLoader::m_instance = nullptr;
  19. AuotTestLoader::AuotTestLoader()
  20. :m_DllFileHandle(nullptr),
  21. m_serverInstance(nullptr),
  22. m_serverActived(FALSE)
  23. {
  24. }
  25. AuotTestLoader::~AuotTestLoader()
  26. {
  27. }
  28. AuotTestLoader *AuotTestLoader::Instance()
  29. {
  30. if (m_instance == nullptr)
  31. {
  32. m_instance = new AuotTestLoader();
  33. m_instance->Initialize();
  34. }
  35. return m_instance;
  36. }
  37. void AuotTestLoader::Initialize()
  38. {
  39. m_serverActived = FALSE;
  40. m_DllFileHandle = LoadLibrary(AutotestFile.c_str());
  41. if (!m_DllFileHandle)
  42. {
  43. return;
  44. }
  45. typedef IAutoTestServer* (*GetAutoTestServer)();
  46. GetAutoTestServer getServer;
  47. getServer = (GetAutoTestServer)GetProcAddress(m_DllFileHandle, "GetAutoTestServer");
  48. if (!getServer)
  49. {
  50. return;
  51. }
  52. m_serverInstance = getServer();
  53. if (!m_serverInstance)
  54. {
  55. return;
  56. }
  57. printf_s("[AuotTestLoader]->[%s loaded.]", AutotestFile.c_str());
  58. m_serverActived = TRUE;
  59. }
  60. IAutoTestServer *AuotTestLoader::GetServerInstance()
  61. {
  62. return m_serverInstance;
  63. }
  64. BOOL AuotTestLoader::IsActived()
  65. {
  66. return m_serverActived;
  67. }