///////////////////////////////////////////////////////////// // Explicit_Load_Component.cpp - load dll on demand // // // // Jim Fawcett, CSE775 - Distributed Objects, Spring 2015 // ///////////////////////////////////////////////////////////// /* * Note: Doesn't need to include Component.Lib in project */ #include // get access to LoadLibrary and GetProcAddress #include #include "../Component/ITest.h" int main() { std::cout << "\n Explicit Loader Demo Client"; std::cout << "\n =============================\n"; std::cout << "\n pretending to test the testdriver\n"; std::cout << "\n attempting to load component dll"; HMODULE hmod = LoadLibrary(L"./Component.dll"); if (!hmod) { std::cout << "\n failed to load Component.dll\n\n"; return 1; } std::cout << "\n Component.dll loaded\n"; std::cout << "\n attempting to get address of globalCreateTest function"; using GCreate = ITest*(*)(); GCreate gCreate = (GCreate)GetProcAddress(hmod, "globalCreateTest"); if (!gCreate) { std::cout << "\n failed to acquire create function\n\n"; return 1; } std::cout << "\n acquired pointer to \"globalCreateTest\"\n"; std::cout << "\n using create function to get interface pointer to live test object"; ITest* pTest = gCreate(); std::cout << "\n using test instance - should return test failed\n"; if (pTest->test()) std::cout << "\n test passed"; else std::cout << "\n test failed"; std::cout << "\n\n"; }