MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / QueryMultiStringValue

Method QueryMultiStringValue

WinArk/RegistryKey.cpp:165–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165_Use_decl_annotations_
166LSTATUS 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_
198LONG RegistryKey::QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) noexcept {

Callers 1

OnInitDialogMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected