libcruft-util/library_win32.cpp

38 lines
948 B
C++
Raw Normal View History

2015-08-10 15:45:56 +10:00
/*
2018-08-04 15:14:06 +10:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2015-08-10 15:45:56 +10:00
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
*/
#include "library_win32.hpp"
#include "win32/except.hpp"
2015-08-10 15:45:56 +10:00
using cruft::detail::win32::library;
2015-08-10 15:45:56 +10:00
///////////////////////////////////////////////////////////////////////////////
library::library (const std::experimental::filesystem::path &path):
m_handle (LoadLibraryA (path.c_str ()))
2015-08-10 15:45:56 +10:00
{
if (!m_handle)
win32::error::throw_code ();
2015-08-10 15:45:56 +10:00
}
//-----------------------------------------------------------------------------
library::~library ()
{
FreeLibrary (m_handle);
}
///////////////////////////////////////////////////////////////////////////////
void*
library::symbol (const char *name)
{
return reinterpret_cast<void*> (GetProcAddress (m_handle, name));
}