#include "stdafx.h" #include "AuotTestLoader.h" #include "IAutoTestServer.h" using namespace DIOS::Dev::Detail::MachineryECOM; #ifdef _WIN64 #ifdef _DEBUG const string AutotestFile = "AutoTest.dll"; #else const string AutotestFile = "AutoTest.dll"; #endif #else #ifdef _DEBUG const string AutotestFile = "AutoTest.dll"; #else const string AutotestFile = "AutoTest.dll"; #endif #endif AuotTestLoader *AuotTestLoader::m_instance = nullptr; AuotTestLoader::AuotTestLoader() :m_DllFileHandle(nullptr), m_serverInstance(nullptr), m_serverActived(FALSE) { } AuotTestLoader::~AuotTestLoader() { } AuotTestLoader *AuotTestLoader::Instance() { if (m_instance == nullptr) { m_instance = new AuotTestLoader(); m_instance->Initialize(); } return m_instance; } void AuotTestLoader::Initialize() { m_serverActived = FALSE; m_DllFileHandle = LoadLibrary(AutotestFile.c_str()); if (!m_DllFileHandle) { return; } typedef IAutoTestServer* (*GetAutoTestServer)(); GetAutoTestServer getServer; getServer = (GetAutoTestServer)GetProcAddress(m_DllFileHandle, "GetAutoTestServer"); if (!getServer) { return; } m_serverInstance = getServer(); if (!m_serverInstance) { return; } printf_s("[AuotTestLoader]->[%s loaded.]", AutotestFile.c_str()); m_serverActived = TRUE; } IAutoTestServer *AuotTestLoader::GetServerInstance() { return m_serverInstance; } BOOL AuotTestLoader::IsActived() { return m_serverActived; }