///////////////////////////////////////////////////////////// // 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"; std::cout << "\n ======================\n"; std::cout << "\n pretending to test the testdriver\n"; HMODULE hmod = LoadLibrary(L"./Component.dll"); if (!hmod) { std::cout << "\n failed to load Component.dll\n\n"; return 1; } using GCreate = ITest*(*)(); GCreate gCreate = (GCreate)GetProcAddress(hmod, "globalCreateTest"); if (!gCreate) { std::cout << "\n failed to acquire create function\n\n"; return 1; } ITest* pTest = gCreate(); if (pTest->test()) std::cout << "\n test passed"; else std::cout << "\n test failed"; std::cout << "\n\n"; }