i am trying to communicate with a dll from an exe and when i add WINAPI in the dll i get a NULL value during the call GetProcAddress().
Sample Code is:
EXE:
typedef int __declspec(dllexport) (WINAPI *fun)(int, int);
int main()
{
HINSTANCE hdll;
fun fp;
int a = 120;
int b = 80;
hdll = LoadLibrary(TEXT("baladll.dll"));
if (hdll != NULL)
{
fp = (fun)GetProcAddress((HMODULE)hdll, "add");
if (fp != NULL)
{
int c = fp(a, b);
printf("\n Add is : %d", c);;
}
}
return 0;
}
DLL:
Header file:
int __declspec(dllexport) WINAPI add(int a, int b);
Source file:
#include "dll.h"
int __declspec(dllexport) WINAPI add(int a, int b)
{
return a + b;
}
When the same code is run without WINAPI call i get a non NULL value in GetProcAddress().
Can anyone help me with this.
Thanks.