| 163 | } |
| 164 | |
| 165 | _Use_decl_annotations_ |
| 166 | LSTATUS RegistryKey::QueryMultiStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars) noexcept { |
| 167 | LONG lRes; |
| 168 | DWORD dwType; |
| 169 | ULONG nBytes; |
| 170 | ULONG nChars; |
| 171 | |
| 172 | ATLASSUME(_hKey); |
| 173 | ATLASSERT(pnChars); |
| 174 | |
| 175 | if (pszValue != nullptr && *pnChars < 2) |
| 176 | return ERROR_INSUFFICIENT_BUFFER; |
| 177 | |
| 178 | nBytes = (*pnChars) * sizeof(WCHAR); |
| 179 | |
| 180 | lRes = ::RegQueryValueEx(_hKey, pszValueName, nullptr, &dwType, |
| 181 | reinterpret_cast<LPBYTE>(pszValue), &nBytes); |
| 182 | if (lRes != ERROR_SUCCESS) |
| 183 | return lRes; |
| 184 | if (dwType != REG_MULTI_SZ) |
| 185 | return ERROR_INVALID_DATA; |
| 186 | nChars = nBytes / sizeof(WCHAR); |
| 187 | if (pszValue != nullptr && (nBytes % sizeof(WCHAR) != 0 || |
| 188 | nChars < 1 || pszValue[nChars - 1] != 0 || |
| 189 | (nChars > 1 && pszValue[nChars - 2] != 0))) |
| 190 | return ERROR_INVALID_DATA; |
| 191 | |
| 192 | *pnChars = nChars; |
| 193 | |
| 194 | return ERROR_SUCCESS; |
| 195 | } |
| 196 | |
| 197 | _Use_decl_annotations_ |
| 198 | LONG RegistryKey::QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) noexcept { |