It is possible to set the homedir through windows registry. But we do not expand environment strings there.
This makes it difficult to set a default for all users as you can only enter absolute paths.
I have a potential customer that wants to move the gnupg homedir into an encrypted subdirectory of the users profile and would need something like "%userprofile%\encrypted_subdir\gnupg" as the GNUPGHOME.
We already do this here: https://dev.gnupg.org/source/gpgol/browse/master/src/common.cpp$125
I think the original code from that is from you @werner I only c++ified it a bit to avoid returning a malloced string.