MCPcopy Create free account
hub / github.com/chrxh/alien / TrySetMultiStringValue

Method TrySetMultiStringValue

external/WinReg/WinReg.hpp:1408–1432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1406
1407
1408inline RegResult RegKey::TrySetMultiStringValue(const std::wstring& valueName,
1409 const std::vector<std::wstring>& data)
1410{
1411 _ASSERTE(IsValid());
1412
1413 // First, we have to build a double-NUL-terminated multi-string from the input data.
1414 //
1415 // NOTE: This is the reason why I *cannot* mark this method noexcept,
1416 // since a *dynamic allocation* happens for creating the std::vector in BuildMultiString.
1417 // And, if dynamic memory allocations fail, an exception is thrown.
1418 //
1419 const std::vector<wchar_t> multiString = detail::BuildMultiString(data);
1420
1421 // Total size, in bytes, of the whole multi-string structure
1422 const DWORD dataSize = static_cast<DWORD>(multiString.size() * sizeof(wchar_t));
1423
1424 return RegResult{ ::RegSetValueExW(
1425 m_hKey,
1426 valueName.c_str(),
1427 0, // reserved
1428 REG_MULTI_SZ,
1429 reinterpret_cast<const BYTE*>(multiString.data()),
1430 dataSize
1431 ) };
1432}
1433
1434
1435inline RegResult RegKey::TrySetBinaryValue(const std::wstring& valueName,

Callers

nothing calls this directly

Calls 2

BuildMultiStringFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected