Mohima Chaudhuri
Mohima Chaudhuri

Reputation: 87

Need help to set DWORD value with python

I am trying to set a DWORD value of 0xFFFFFFFF in Windows registry. But when I try this:

_winreg.SetValueEx(aKey,"dword_test_2",0, _winreg.REG_DWORD, 4294967295L )

it throws an error:

ValueError: Could not convert the data to the specified type.

Please help..

Upvotes: 0

Views: 5189

Answers (2)

Krumelur
Krumelur

Reputation: 32497

In Python, using the L suffix to a number creates a value of type long. The long is an integer of arbitrary size. The DWORD likely corresponds to an int in Python.

Did you try

_winreg.SetValueEx(aKey,"dword_test_2",0, _winreg.REG_DWORD, 0xFFFFFFFF )

or

_winreg.SetValueEx(aKey,"dword_test_2",0, _winreg.REG_DWORD, -1 )

?

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798516

Oh yeah, this. I think you need to use -1 instead.

Upvotes: 1

Related Questions