Home > Software engineering >  Why does RegOpenKeyExA fail to open a key path with a space in the name?
Why does RegOpenKeyExA fail to open a key path with a space in the name?

Time:07-11

Why does RegOpenKeyExA throw a path not found error according to the error codes from Microsoft image


BTW, KEY_WRITE includes KEY_SET_VALUE (among others), and KEY_READ includes KEY_QUERY_VALUE (among others), so technically you are opening the key with just KEY_WRITE|KEY_READ. Which is likely to fail unless your program is running with elevated permissions, since most of HKEY_LOCAL_MACHINE is read-only to non-admin users. It is rarely of good idea to open a key under HKEY_LOCAL_MACHINE for both read and write permissions at the same time. If you need to read something, open the key for read-only access, which is likely to succeed. If you need to write something, open the key for write-only access, which will succeed only if you have permission to write.

  • Related