First of all yes I have searched this for a while now and can't find any answers relevant to my case. Basically I am trying to get the address of a function in a windows DLL (dnsapi.dll) and GetProcAddress is returning 0. After a while of scratching my head I even went on to create a program which simply uses GetProcAddress of MessageBox in user32.dll. Same result. Here is the code of the second program I made which still doesn't work:
#include <stdio.h>
#include <Windows.h>
int main() {
HINSTANCE hLib = LoadLibrary(TEXT("user32.dll"));
DWORD MsgBoxAddr = (DWORD)GetProcAddress(hLib, "MessageBox");
printf("%ld", MsgBoxAddr);
getchar();
return 0;
}
BTW GetLastError returns 127 which seems to be the most common error returned when GetProcAddress doesn't work but I can't figure out what is wrong, I have tried with many functions and DLL's, not just these couple.
Thanks. :)
EDIT: The linked article solved my problem, the functions I tried all had unicode and anis versions (w and a). Using the full API names solved the problems. Thanks for linking that question.
Thank you.