iw4x-client/src/Utils/Library.cpp

30 lines
520 B
C++
Raw Normal View History

2016-09-16 18:14:59 -04:00
#include "STDInclude.hpp"
namespace Utils
{
Library::Library(std::string buffer, bool _freeOnDestroy) : freeOnDestroy(_freeOnDestroy), module(nullptr)
2016-09-16 18:14:59 -04:00
{
this->module = LoadLibraryExA(buffer.data(), NULL, 0);
2016-09-16 18:14:59 -04:00
}
Library::~Library()
{
if (this->freeOnDestroy && this->valid())
2016-09-16 18:14:59 -04:00
{
FreeLibrary(this->getModule());
2016-09-16 18:14:59 -04:00
}
this->module = nullptr;
2016-09-16 18:14:59 -04:00
}
bool Library::valid()
2016-09-16 18:14:59 -04:00
{
return (this->getModule() != nullptr);
2016-09-16 18:14:59 -04:00
}
HMODULE Library::getModule()
2016-09-16 18:14:59 -04:00
{
return this->module;
2016-09-16 18:14:59 -04:00
}
}