Platform SDK: RAS/Routing and RAS |
The RasEnumEntries function lists all entry names in a remote access phone book.
DWORD RasEnumEntries ( LPCTSTR reserved, // reserved, must be NULL LPTCSTR lpszPhonebook, // pointer to full path and // file name of phone-book file LPRASENTRYNAME lprasentryname, // buffer to receive // phone-book entries LPDWORD lpcb, // size in bytes of buffer LPDWORD lpcEntries // number of entries written // to buffer );
Windows 2000: If this paramter is NULL, the entries are enumerated from all the remote access phone-book files in the AllUsers profile and the user's profile.
Windows 95: This parameter is ignored. Dial-up networking stores phone-book entries in the registry rather than in a phone-book file.
If the function succeeds, the return value is zero.
If the function fails, the return value is a nonzero error value listed in the RAS header file or one of the following values.
Value | Meaning |
---|---|
ERROR_BUFFER_TOO_SMALL | The buffer pointed to by the lprasentryname parameter is not large enough to hold all the entries. |
ERROR_INVALID_SIZE | The value of dwSize in the RASENTRYNAME structure pointed to by lprasentryname, specifies a version of the structure that is not supported on the current platform. For example, on Windows 95, RasEnumEntries returns this error if dwSize indicates that RASENTRYNAME includes the dwFlags and szPhonebookPath members, since these members are not supported on Windows 95 (they are supported only on Windows 2000 and later). |
ERROR_NOT_ENOUGH_MEMORY | The function could not allocate sufficient memory to complete the operation. |
The following sample code enumerates the RAS phone-book entries on the current machine. The code initially calls RasEnumEntries to obtain the size of the buffer to pass in. The code then calls RasEnumEntries again, to enumerate the entries. Note that for both calls, the code sets the dwSize member of the first RASENTRY structure in the buffer to sizeof(RASENTRY) to specify the structure version.
lpRasEntryName = (LPRASENTRYNAME)GlobalAlloc(GPTR, sizeof(RASENTRYNAME)); lpRasEntryName->dwSize = sizeof(RASENTRYNAME); if ((nRet = RasEnumEntries(NULL, NULL, lpRasEntryName, &cb, &cEntries)) == ERROR_BUFFER_TOO_SMALL) { lpRasEntryName = (LPRASENTRYNAME)GlobalAlloc(GPTR, cb); lpRasEntryName->dwSize = sizeof(RASENTRYNAME); } // Calling RasEnumEntries to enumerate the phone-book entries nRet = RasEnumEntries(NULL, NULL, lpRasEntryName, &cb, &cEntries); if (nRet != ERROR_SUCCESS) { printf("RasEnumEntries failed: Error %d\n", nRet); } else { printf("Phone-book entries in the default phone book:\n\n"); for(i=0;i < cEntries;i++) { printf("%s\n",lpRasEntryName->szEntryName); lpRasEntryName++; } }
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Ras.h.
Library: Use Rasapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Remote Access Service (RAS) Overview, Remote Access Service Functions, RASENTRYNAME, RasEnumConnections