Skip to content

Add open_current_user_key registry helpers - #639

Open
Ben Hillis (benhillis) wants to merge 1 commit into
microsoft:masterfrom
benhillis:reg-open-current-user
Open

Add open_current_user_key registry helpers#639
Ben Hillis (benhillis) wants to merge 1 commit into
microsoft:masterfrom
benhillis:reg-open-current-user

Conversation

@benhillis

Copy link
Copy Markdown
Member

Adds wil::reg::open_current_user_key[_nothrow] and the shared-key variants, wrapping RegOpenCurrentUser. Includes Catch2 [registry] tests (read/write through the hive and read-only enforcement via a directly-written read-only handle) passing in normal & noexcept configs. Part of enabling WSL to drop its in-house registry helper in favor of wil::reg.

@benhillis
Ben Hillis (benhillis) marked this pull request as ready for review June 18, 2026 17:22
Comment thread include/wil/registry.h
* @return A wil::shared_hkey containing the resulting opened HKEY
* @exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline ::wil::shared_hkey open_current_user_shared_key(::wil::reg::key_access access = ::wil::reg::key_access::read)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change required - are there other examples of duplicating the shared/unique overloads? You should always be able to transfer a unique into a shared if necessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - let me check...

Add wil::reg::open_current_user_key[_nothrow] (and shared_hkey variants
gated on __WIL_WINREG_STL) wrapping RegOpenCurrentUser, which resolves
the HKEY_CURRENT_USER subtree for the user the calling thread is
impersonating rather than the process user.

Follows the existing nothrow-core plus throwing-wrapper pattern and adds
RegistryTests coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants