RasGetErrorString function

The RasGetErrorString function obtains an error message string for a specified RAS error value.

Syntax


DWORD RasGetErrorString(
  _In_  UINT   uErrorValue,
  _Out_ LPTSTR lpszErrorString,
  _In_  DWORD  cBufSize
);

Parameters

uErrorValue [in]

Specifies the error value of interest. These are values returned by one of the RAS functions: those listed in the RasError.h header file.

lpszErrorString [out]

Pointer to a buffer that receives the error string. This parameter must not be NULL.

cBufSize [in]

Specifies the size, in characters, of the buffer pointed to by lpszErrorString.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is one of the following error codes or a value from Routing and Remote Access Error Codes or Winerror.h. There is no GetLastError information set by the RasGetErrorString function.

ValueMeaning
ERROR_INVALID_PARAMETER

An invalid parameter was passed into the function.

 

Remarks

There is no way to determine in advance the exact size in characters of an error message, and thus the size of buffer required. Error messages will generally be 80 characters or fewer in size; a buffer size of 512 characters will always be adequate. A buffer of insufficient size causes the RasGetErrorString function to fail, returning ERROR_INSUFFICIENT_BUFFER. Note that buffer sizes are specified in characters, not bytes; thus, the Unicode version of RasGetErrorString requires at least a 1024 byte buffer to guarantee that every error message fits.

Examples

The following code obtains an error string for the RAS error 633.



#include <windows.h>
#include <stdio.h>
#include "ras.h"
#include "rasdlg.h"
#include <tchar.h>

#define  ERROR_VAL 633
#define  BUFFER_SIZE 256

DWORD __cdecl wmain(){

    DWORD dwRetVal = ERROR_SUCCESS;
    UINT  uErrorValue = ERROR_VAL;
    DWORD cBufSize = BUFFER_SIZE;
    WCHAR lpszErrorString[BUFFER_SIZE];

    dwRetVal = RasGetErrorString(uErrorValue, lpszErrorString, cBufSize);

    if(dwRetVal == ERROR_SUCCESS){
        wprintf(L"Error Code %d: %s\n", uErrorValue, lpszErrorString);
    }else{
           wprintf(L"RasGetErrorString failed, Return Value: %d", dwRetVal);
    }

    return 0;
}


Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Ras.h

Library

Rasapi32.lib

DLL

Rasapi32.dll

Unicode and ANSI names

RasGetErrorStringW (Unicode) and RasGetErrorStringA (ANSI)

See also

Remote Access Service (RAS) Overview
Remote Access Service Functions
GlobalAlloc
LoadString

 

 

Community Additions

ADD
Show: