error LNK2001: unresolved external symbol _RasGetErrorStringA@12
error LNK2001: unresolved external symbol _RasEnumEntriesA@20
I am not able to use this RAS functions
so please tell what's wrong in this code
#include <ras.h>
#include <raserror.h>
BOOL CMy2NetDialDlg::QueryConnections()
{
typedef DWORD (WINAPI* RGEPA)
(LPCTSTR lpszPhonebook, // pointer to full path and filename of
// phone-book file
LPCTSTR lpszEntry, // pointer to an entry name
LPRASENTRY lpRasEntry, // buffer that receives entry information
LPDWORD lpdwEntryInfoSize, // size, in bytes, of the lpRasEntry
// buffer
LPBYTE lpbDeviceInfo, // buffer that receives device-specific
// configuration information
LPDWORD lpdwDeviceInfoSize // size, in bytes, of the
// lpbDeviceInfo buffer
);
// load library
HINSTANCE hLib = LoadLibrary(_T("RASAPI32.DLL"));
// HINSTANCE hLib = LoadLibrary("C:\\WINDOWS\\system32\\RASAPI32.DLL");
// AfxMessageBox("LoadLibrary(_T(RASAPI32.DLL))");
if (NULL == hLib) return FALSE;
RGEPA rgepa = (RGEPA) GetProcAddress(hLib, "RasGetEntryPropertiesA");
if (NULL == rgepa)
{
::FreeLibrary(hLib);
return FALSE;
}
RASENTRY RasEntry;
DWORD dw = sizeof(RASENTRY);
ZeroMemory(&RasEntry, dw);
RasEntry.dwSize = dw;
DWORD ret = rgepa(NULL, NULL, &RasEntry, &dw, NULL, NULL);//sEntryName
// ::FreeLibrary(hLib);
LPRASENTRYNAME first_ras_entry; // really a buffer of [num_entries]
DWORD buf_size, entry_size;
DWORD num_entries = 1;
DWORD dwRet;//retval
UINT ndx;
char szMessage[256];
CString sProvdrTmp;
entry_size = sizeof(RASENTRYNAME);
buf_size = entry_size * num_entries;
first_ras_entry = (LPRASENTRYNAME) new char[buf_size];
// check for a malloc() failure
if (NULL == first_ras_entry) return FALSE;
// clear the whole buffer, rather than a single entry
ZeroMemory(first_ras_entry, buf_size); // AKA bzero() or memset(0)
first_ras_entry->dwSize = entry_size; // initialize the dwSize member
dwRet = RasEnumEntries(NULL, NULL, first_ras_entry, &buf_size, &num_entries);
if( (ERROR_BUFFER_TOO_SMALL == dwRet) // entry size OK, but too many entries
|| (ERROR_INVALID_SIZE == dwRet) ) // entry size wrong
{
entry_size = buf_size / num_entries; // recalculate the correct entry size
// reallocate the buffer:
delete first_ras_entry;
first_ras_entry = NULL;
first_ras_entry = (LPRASENTRYNAME) new char[buf_size];
if (NULL != first_ras_entry) // if buffer OK, try again
{
ZeroMemory(first_ras_entry, buf_size);
first_ras_entry->dwSize = entry_size;
dwRet = RasEnumEntries(NULL, NULL, first_ras_entry, &buf_size, &num_entries);
}
else
dwRet = ERROR_NOT_ENOUGH_MEMORY;
}
if (0 != dwRet) // other error
{
long int tmp_dwRet;
tmp_dwRet = RasGetErrorString((UINT)dwRet, szMessage, 256);
if (0 == tmp_dwRet)
{
AfxMessageBox( szMessage);
CString sss; //sss.LoadString(IDS_RASCS_25);
wsprintf((LPSTR)szMessage, sss);
}
else
{
AfxMessageBox("Couldn't get a verbose err. message. RasGetErrorString() = %ld", tmp_dwRet);
}
UpdateData(FALSE);
}
if (0 == num_entries)
{
delete first_ras_entry;
return FALSE;
}
BOOL bSet = FALSE;
if (0 == dwRet) // No errors
{
for (ndx = 0; ndx < num_entries; ndx++)
{
sProvdrTmp =(CString)first_ras_entry[ndx].szEntryName;
if (first_ras_entry[ndx].szEntryName == sCurrentProvider)
{
bSet = TRUE;
}
}
if (!bSet)
{
sCurrentProvider = sProvdrTmp;//first_ras_entry[ndx].szEntryName;
}
}
::FreeLibrary(hLib);
delete first_ras_entry;
return TRUE;
}

New Topic/Question
Reply




MultiQuote




|