Probably your application has not the right privileges needed to open a
HKEY_LOCAL_MACHINE
subtree. Anyway you have to check the return value code, as per the
documentation[
^] :
If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.