In the code below, I check if test.dll has been loaded, and it always returns false... I can't figure out what I'm doing wrong. Can anyone give me a hand?
P.S.: I've triple checked that the DLL is in the running directory.
#include <iostream>
#include <windows.h>
typedef int (*AddFunc)(int,int);
typedef void (*FunctionFunc)();
int main()
{
AddFunc _AddFunc;
FunctionFunc _FunctionFunc;
HINSTANCE hInstLibrary = LoadLibrary((LPCTSTR)("test.dll"));
if (hInstLibrary)
{
_AddFunc = (AddFunc)GetProcAddress(hInstLibrary, "Add");
_FunctionFunc = (FunctionFunc)GetProcAddress(hInstLibrary,
"Function");
if (_AddFunc)
{
std::cout << "23 = 43 = " << _AddFunc(23, 43) << std::endl;
}
if (_FunctionFunc)
{
_FunctionFunc();
}
FreeLibrary(hInstLibrary);
}
else
{
std::cout << "DLL Failed To Load!" << std::endl;
}
std::cin.get();
return 0;
}