
Calling RAS API functions without linking to DLL
Hello,
I've got some code which calls the RasEnumConnections function from the
RAS api, but I don't want to link to the DLL, so I used the method of
getting the Module handle.
Here is the code I am using:
DWORD dwConnections;
RASCONN rasconn;
rasconn.dwSize = sizeof(RASCONN);
DWORD dwSize = rasconn.dwSize;
DWORD dwSuccess;
typedef DWORD (WINAPI *fp_RasEnunCons)(LPRASCONN lprasconn, LPDWORD lpcb,
LPDWORD lpcConnections );
fp_RasEnunCons fncptr1 = NULL;
HMODULE hModule = ::GetModuleHandle(TEXT("RASAPI32"));
fncptr1 = (fp_RasEnunCons)::GetProcAddress(hModule, "RasEnumConnectionsA");
if (fncptr1 != NULL)
{
DWORD dwSuccess = (*fncptr1)(&rasconn, &dwSize, &dwConnections);
Quote:
}
else
{
Quote:
}
The Problem is, that fncptr1 ends up being NULL.
Can someone please tell me what I am doing wrong.
Thank you.
Nulogica