I am having difficulty do understand this. If I'm correct, A 32bit Python can't run a code and change registry values in 64bit. Do I get it right? Or is there a switch to turn on in which enables this functionality?

There is this: http://msdn.microsoft.com/en-us/library/aa384129%28v=VS.85%29.aspx

But how do I use it with the following code? http://www.blog.pythonlibrary.org/2010/03/20/pythons-_winreg-editing-the-windows-registry/

Thanks, Oz

  • You should just be able to replace KEY_ALL_ACCESS with (KEY_ALL_ACCESS <bitwise or> KEY_WOW64_64KEY). If KEY_WOW64_64KEY isn't defined, use the explicit value 0x0100. Dec 15, 2011 at 20:51
  • replace where? what is Flag in Windows terminology???
    – oz123
    Dec 16, 2011 at 10:46
  • Where the existing code says KEY_ALL_ACCESS. A flag is a parameter, or a single bit in a parameter, which changes the behaviour of a function call. Jan 9, 2012 at 22:27

1 Answer 1


edit: Sorry, I misunderstood the question. Do the flag thing. :p

If you are on a 64bit operating system, you will have a "folder" in the HKLM\Software and HKCU\Software keys named Wow6432Node. That is like a junction point that allows Windows to maintain backwards compatibility across architectures, and basically transparently redirects the 32bit program that is accessing the registry.


So even if you are executing 32bit code, if you are on a 64bit version of Windows, modifying HKLM\Software\Mysoftware is the 64bit registry. If you needed to modify the 32bit registry, it would HKLM\Software\Wow6432Node\MySoftware.

Here I am about to set 32bit ODBC connections, even on a 64bit OS. It also works on a 32bit OS. No flag setting is required. This code works.


  • 2
    -1, this is wrong. 32-bit code accessing HKLM\Software\Mysoftware is NOT modifying the 64-bit registry, it is transparently redirected to HKLM\Software\Wow6432Node\MySoftware unless you explicitly specify KEY_WOW64_64KEY. Jan 9, 2012 at 6:04
  • While I appreciate your candorous downvote, this 32bit code 100% works on both 32bit and 64bit versions of Windows. When on a 64bit OS you just have to be mindful of whether the key you want is actually down Wow6432Node or not. No flag-setting is required. I did not say that playing with the KEY_WOW64_64KEY flags will not work or is not an alternative, I'm just saying that you do not have to do it that way. If it was my wording that you disagreed with, then let the code speak for itself.
    – Ryan Ries
    Jan 9, 2012 at 14:20
  • @RyanRies You should replace the screenshot of code with a code block containing the code.
    – jscott
    Jan 9, 2012 at 14:23
  • You don't need to set a flag if you're wanting to write to the 32-bit view, from either 32-bit or 64-bit apps. But this question is about writing to the 64-bit view from a 32-bit app. So, depending on interpretation, your answer is either wrong or irrelevant to the question. Jan 9, 2012 at 22:01
  • Regarding your code fragment: assuming this is meant to be 32-bit code as stated, you don't need to use Wow6432Node. The two paths are equivalent, so the if statement is redundant. Jan 9, 2012 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.