How do I delete a registry entry in Windows x64 in the 64 bit tree without using RegDeleteKeyEx in C++?

StackOverflow https://stackoverflow.com/questions/1476749

  •  16-09-2019
  •  | 
  •  

Question

I'm working on an 32 installer that has to run on environments ranging from Win XP upwards. We have a problem where we have to remove a registry entry on the x64 section of the registry under Windows 2k3 x64.

That's easy enough with RegDeleteKeyEx, but I can't distribute an executable that might call that function because it won't run on Windows XP. I can get a handle to the key easily enough, I just can't see how I'm supposed to delete it.

I can't use RegDeleteKey because registry redirection will thwart my efforts on x64 platforms. I'm annoyed I can't just pass it a handle to my key, and an empty/null subkey string. I can't believe this API was so broken. Am I missing something?

My only idea at the moment to call out to a registry file or a separate executable to do the job for me, but that's just incredibly ugly and only makes a fugly workaround even worse. Is there a better way?

Was it helpful?

Solution

Why not resolving RegDeleteKeyEx at run-time (using LoadLibrary, GetModuleHandle or similar and GetProcAddress) after you have determined, that the system is a x64 one?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top