Platform SDK: RAS/Routing and RAS

RasEnumDevices

The RasEnumDevices function returns the name and type of all available RAS-capable devices.

DWORD RasEnumDevices(
  LPRASDEVINFO lpRasDevInfo,  // buffer to receive
                              //  information about RAS devices
  LPDWORD lpcb,               // size, in bytes, of the buffer
  LPDWORD lpcDevices          // receives the number of
                              //  entries written to the buffer
);

Parameters

lpRasDevInfo
Pointer to a buffer that receives an array of RASDEVINFO structures, one for each RAS-capable device. Before calling the function, set the dwSize member of the first RASDEVINFO structure in the buffer to sizeof(RASDEVINFO) to identify the version of the structure.
lpcb
Pointer to a variable that contains the size, in bytes, of the lpRasDevInfo buffer. On return, the function sets this variable to the number of bytes required to enumerate the devices.

To determine the required buffer size, call RasEnumDevices with the lpRasDevInfo parameter set to NULL and the variable pointed to by lpcb set to zero. The function returns the required buffer size in the variable pointed to by lpcb. (See sample code under Remarks section.)

lpcDevices
Pointer to a variable that the function sets to the number of RASDEVINFO structures written to the lpRasDevInfo buffer.

Return Values

If the function succeeds, the return value is zero.

If the function fails, the return value is a nonzero RAS error value or one of following error codes.

Value Meaning
ERROR_BUFFER_TOO_SMALL The lpRasDevInfo buffer is not large enough. The function returns the required buffer size in the variable pointed to by lpcb.
ERROR_NOT_ENOUGH_MEMORY Indicates insufficient memory.
ERROR_INVALID_PARAMETER Indicates an invalid parameter value.
ERROR_INVALID_USER_BUFFER The address or buffer specified by lpRasDevInfo is invalid.

Remarks

The following sample code enumerates the devices on the current machine. The code initially calls RasEnumDevices with a lpRasDevInfo parameter of NULL, to obtain the size of the buffer that should be passed in. The code also sets the dwSize member of the first RASDEVINFO structure to sizeof(RASDEVINFO) to specify the version of the structure.

RasEnumDevices(NULL, &lpcb, &lpcDevices);
lpRasDevInfo = (LPRASDEVINFO) GlobalAlloc(GPTR, lpcb);
lpRasDevInfo->dwSize = sizeof(RASDEVINFO);
 
nRet = RasEnumDevices(lpRasDevInfo, &lpcb, &lpcDevices);
if (nRet != 0)
{
    printf("RasEnumDevices failed: Error %d", nRet);
}
else
{
    printf("The following RAS capable devices were found on this machine:\n\n");
    for (i=0; i < lpcDevices; i++)
    {
        printf("%s\n",lpRasDevInfo->szDeviceName);
        lpRasDevInfo++;
    }
}

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 OSR2 or later.
  Header: Declared in Ras.h.
  Library: Use Rasapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

Remote Access Service (RAS) Overview, Remote Access Service Functions, RASDEVINFO