Some questions about wil::reg
petercoin opened this issue · comments
Peter Wu commented
Hello,
I have taken a look at wil::reg and have a few questions that I was hoping you could clarify:
- Is there a specific reason for using PCWSTR for subkey and value_name instead of std::wstring?
- In reference to the Remarks provided for RegOpenKeyExW, would it be more appropriate to use RegOpenCurrentUser for HKEY_CURRENT_USER?
Thank you for your assistance and insights. Looking forward to your response.
Best regards.
Duncan Horn commented
Regarding your first question:
- Not all consumers of WIL have access to the STL, so any code that uses STL types must be guarded, limiting their usefulness. This has a cascading effect where any functions using those functions must also be guarded
- For input, none of the Windows APIs accept
std::basic_string
, so using that for input params would needlessly require consumers to construct one, wasting time and memory - For output,
std::basic_string
is a terrible API to use for output buffers due to the lack of some form ofuninitialized_resize
that would allow us to change the underlying buffer size without needlessly writing zeros to the soon-to-be overwritten or discarded memory
Fulgen301 commented
due to the lack of some form of
uninitialized_resize
For the sake of completion: C++23 has introduced resize_and_overwrite
, although this doesn't help with older C++ standards of course.
Duncan Horn commented
Huh, good to know, I missed that. But yeah, the C++ version requirement (the Windows codebase is still on C++17 as the default AFAIK) and all other issues still apply.