dllLoader.cpp 818 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "dllLoader.h"
  2. #include "pikaConfig.h"
  3. #ifdef PIKA_DEVELOPMENT
  4. #ifdef PIKA_WINDOWS
  5. #define NOMINMAX
  6. #define WIN32_LEAN_AND_MEAN
  7. #include <Windows.h>
  8. static HMODULE dllHand;
  9. //todo error reporting with strings
  10. bool pika::loadDll(std::filesystem::path path, testPrint_t **testPrint)
  11. {
  12. path /= "pikaGameplay.dll";
  13. dllHand = LoadLibraryA(path.string().c_str());
  14. if (!dllHand) { return false; }
  15. *testPrint = (testPrint_t *)GetProcAddress(dllHand, "testPrint");
  16. if (!testPrint) { return false; }
  17. return true;
  18. }
  19. #else
  20. #error "pika load dll works only on windows."
  21. #endif
  22. #elif defined(PIKA_PRODUCTION)
  23. #include <dllMain.h>
  24. bool pika::loadDll(std::filesystem::path path, testPrint_t **testPrint_)
  25. {
  26. *testPrint_ = testPrint;
  27. return true;
  28. }
  29. #endif