I have a dll and header file. Now I am creating a console application using vs2015. and load this library. But while getting GetProcAddress of function. It is always returning NULL. Here is my code. Contents of header file (test.h) (This header file is only for your reference)
#ifdef APPLYDLL_EXPORTS
#define APPLYDLL_API __declspec(dllexport)
#else
#ifdef BUILD_EXE
#define APPLYDLL_API
#else
#define APPLYDLL_API __declspec(dllimport)
#endif
#endif
#include <string>
#include <winerror.h>
APPLYDLL_API HRESULT ApplySettings(std::string input);
Contents of console application (cpp file)
#include "stdafx.h"
#include <Windows.h>
#include <string>
using namespace std;
//Define the function prototype
typedef HRESULT(CALLBACK* ApplySettings)(std::string);
int main()
{
HINSTANCE hLib = LoadLibrary(TEXT("ApplyTool.dll"));
if (NULL != hLib)
{
//Get pointer to our function using GetProcAddress:
ApplySettings applySettings = (ApplySettings)GetProcAddress(hLib,"ApplySettings");
DWORD errorcode=GetLastError(); //errorcode 127, Procedure not Found
}
return 0;
}
I don't know, Where I am doing silly mistake.
Someone please help me.
Thanks in adv.