Share via


RasEnumEntries (Windows Embedded CE 6.0)

1/6/2010

This function lists all entry names in a remote access phone book.

Syntax

DWORD RasEnumEntries(
  LPWSTR Reserved, 
  LPWSTR lpszPhoneBookPath, 
  LPRASENTRYNAME lprasentryname, 
  LPDWORD lpcb, 
  LPDWORD lpcEntries 
);

Parameters

  • Reserved
    Reserved; set to NULL.
  • lpszPhoneBookPath
    This parameter is ignored. Dial-up networking stores phone-book entries in the registry rather than in a phone-book file.
  • lprasentryname
    Pointer to a buffer that receives an array of RASENTRYNAME structures, one for each phone-book entry. Before calling the function, an application must set the dwSize member of the first RASENTRYNAME structure in the buffer to sizeof(RASENTRYNAME) in order to identify the version of the structure being passed.
  • lpcb
    Pointer to a variable that that contains the size, in bytes, of the buffer specified by lprasentryname. On return, the function sets this variable to the number of bytes required to successfully complete the call.
  • lpcEntries
    Pointer to a variable that the function, if successful, sets to the number of phone-book entries written to the buffer specified by lprasentryname.

Return Value

Zero indicates success. A nonzero error value listed in the RAS header file, ERROR_BUFFER_TOO_SMALL, or ERROR_NOT_ENOUGH_MEMORY indicates failure.

Include Raserror.h for definitions of the RAS error codes.

Remarks

The following sample code enumerates the RAS phonebook 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)LocalAlloc(LPTR, sizeof(RASENTRYNAME));
lprasentryname->dwSize = sizeof(RASENTRYNAME);
if ((nRet = RasEnumEntries(NULL, NULL, lprasentryname, &cb, &cEntries)) 
    == ERROR_BUFFER_TOO_SMALL)
{
    lprasentryname = (LPRASENTRYNAME)LocalAlloc(LPTR, cb);
    lprasentryname->dwSize = sizeof(RASENTRYNAME);
}
// Calling RasEnumEntries to enumerate the phonebook 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 phonebook:\n\n");
    for(i=0;i < cEntries;i++)
    {
        printf("%s\n",lprasentryname->szEntryName);
        lprasentryname++;
    }
}

Requirements

Header ras.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later

See Also

Reference

RAS Functions
RasEnumConnections
RASENTRYNAME