The GetRoleText function retrieves the localized string that describes an object's role for the specified role value.

UINT GetRoleText(
  DWORD dwRole,
  LPTSTR lpszRole,
  UINT cchRoleMax


[in] One of the object role constants.
[out] Address of a buffer that receives the role text string. If this parameter is NULL, the function returns the role string's length, not including the null character.
[in] The size of the buffer pointed to by the lpszRole parameter. For ANSI strings, this value is measured in bytes. For Unicode strings, it is measured in characters.

Return Values

If successful, and lpszRole is non-NULL, the return value is the number of bytes (ANSI version) or characters (Unicode version) copied into the buffer, not including the terminating null character. If lpszRole is NULL, then the return value represents the string's length, not including the null character.

If the string resource does not exist, or if the lpszRole parameter is not a valid pointer, the return value is zero (0). To get extended error information, call GetLastError.


See the client example at IAccessible::get_accRole.


  Windows NT/2000/XP/Server 2003: Included in Windows 2000 and later.
  Windows 95/98/Me: Included in Windows 98 and later.
  Redistributable: Requires Active Accessibility 1.3 RDK on Windows NT 4.0 SP6 and Windows 95.
  Header: Declared in Oleacc.h.
  Library: Use Oleacc.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP/Server 2003.

Community Additions