Menu

#456 TRegistry::Update and Validate do not work

6.44
closed
1
2020-04-29
2020-04-17
No

TRegistry::Update reads a configuration stream and writes the entries to the Windows Registry. TRegistry::Validate reads the same configuration stream and verifies that the Windows Registry contains the same entries.

:::C++
//
/// Walks through an input stream and uses  basekey\\key\\key=data  lines to set
/// registry entries.
///
/// Has named value support in the form:    basekey\\key\\key|valuename=data
//
void TRegistry::Update(TRegKey& baseKey, tistream& in)
[...]

//
/// Walks through an input stream and uses  basekey\\key\\key=data  lines to check
/// registry entries.
/// Returns the number of differences. Zero means a complete match.
///
/// Has named value support in the following form:  basekey\\key\\key|valuename=data
//
int TRegistry::Validate(TRegKey& baseKey, tistream& in)
[...]

However, Update fails to write named values at all — it only works for the default values associated with each key (which was all 16-bit Windows supported, before introducing named values in 32-bit Windows; ref. TheOldNewThing). Also, it fails to write the default value for the base key — it assumes a subkey is always specified (i.e. "basekey=data" fails).

For example:

:::C++
auto s = tstringstream{};

#if 0 // This simple test should work for 6.44.9 and earlier.

s << _T("OWLNext_RegTest\\Key1=Key1DefaultText\n")
  << _T("OWLNext_RegTest\\Key2 = Key2DefaultText\n")
  << _T("OWLNext_RegTest\\Key3  =  Key3DefaultText\n");

#else // This tougher test fails on 6.44.9 and earlier.

s << _T("OWLNext_RegTest=DefaultText\n")
  << _T("OWLNext_RegTest|Value1=Text1\n")
  << _T("OWLNext_RegTest|Value2 = Text2\n")
  << _T("OWLNext_RegTest|Value3  =  Text3\n")
  << _T("OWLNext_RegTest\\Key1  =  Key1DefaultText\n")
  << _T("OWLNext_RegTest\\Key1|Key1Value1=Key1Text1\n")
  << _T("OWLNext_RegTest\\Key1|Key1Value2 = Key1Text2\n")
  << _T("OWLNext_RegTest\\Key1|Key1Value3  =  Key1Text3\n");

#endif

auto testKey = TRegKey{HKEY_CURRENT_USER, _T("OWLNext_RegTest")};
TRegistry::Update(testKey, s);
s.clear();
s.seekg(0);
const auto diff = TRegistry::Validate(testKey, s);

Note that the OWLNext code for these functions remains largely unchanged since OWL 5, so these issues do not appear to be regressions in OWLNext. Hence I presume the need for these functions is minimal, if existent at all. I have a fix in the making, but perhaps we should deprecate these functions on the trunk?

Related

Feature Requests: #151
Wiki: Coding_Standards
Wiki: OWLNext_Stable_Releases

Discussion

  • Vidar Hasfjord

    Vidar Hasfjord - 2020-04-17
    • status: open --> pending
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2020-04-29
    • Status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB