Поделиться через


CRegKey::QueryStringValue

Call this method to retrieve the string data for a specified value name.

LONG QueryStringValue(
   LPCTSTR pszValueName,
   LPTSTR pszValue,
   ULONG* pnChars 
) throw( );

Параметры

  • pszValueName
    Pointer to a null-terminated string containing the name of the value to query.

  • pszValue
    Pointer to a buffer that receives the string data.

  • pnChars
    The size, in TCHARs, of the buffer pointed to by pszValue. When the method returns, pnChars contains the size, in TCHARs, of the string retrieved, including a terminating null character.

Возвращаемое значение

If the method succeeds, ERROR_SUCCESS is returned. If the method fails to read a value, it returns a nonzero error code defined in WINERROR.H. If the data referenced is not of type REG_SZ, ERROR_INVALID_DATA is returned. If the method returns ERROR_MORE_DATA, pnChars equals zero, not the required buffer size in bytes.

Заметки

This method makes use of RegQueryValueEx and confirms that the correct type of data is returned. See RegQueryValueEx for more details.

Примечание о безопасностиПримечание о безопасности.

This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the RegQueryValueEx function used by this method does not explicitly handle strings which are NULL terminated. Both conditions should be checked for by the calling code.

Требования

Header: atlbase.h

См. также

Основные понятия

CRegKey Class

CRegKey Members

CRegKey::SetStringValue

CRegKey::QueryBinaryValue

CRegKey::QueryDWORDValue

CRegKey::QueryGUIDValue

CRegKey::QueryMultiStringValue

CRegKey::QueryQWORDValue