I was thinking it would be cool to have a few classes to wrap around LoadLibrary
and GetProcAddress
, Library
and Function
respectively. As I was thinking about this I'm not sure its possible. Here is what I'm thinking:
Library
class:
class Library
{
HANDLE m_handle;
public:
// Handles initializing the DLL:
Library(std::string name);
// Deinitializes the DLL
~Library();
HANDLE getHandle();
bool isInitialized();
}
And the Function
class:
class Function
{
public:
Function(Library& library, std::string name);
void* call(/* varg arguments? */) throw(exception);
bool isValid();
}
Problem arises because I have to have dynamic data types for the parameters and multiple lengths to pass to the real function pointer. I could get around the multiple lengths of the arguments by specifying it in the constructor and have specific methods but what about the data types?
EDIT: I've created classes based on the answers for anyone to use here: https://github.com/ic3man5/ice--