[python-win32] writing DWORD values > 0x7ffffff

Scott Leerssen sleerssen at gmail.com
Mon Mar 26 21:35:44 CEST 2012


On Mar 26, 2012, at 3:20 PM, Tim Roberts wrote:

> Scott Leerssen wrote:
>> I'm trying to write a DWORD value to the registry using _winreg.SetValueEx and anything greater than 0x7fffffff yields a "ValueError: Could not convert the data to the specified type."  I've seen a few posts saying that taking the complement of the large integer (basically making it a negative value) satisfies the API and fools it into storing the value, but that has the same result in my experiments.  Any hints as to how to write large integers int a DWORD?
> 
> Ugly but functional:
>   dw = struct.unpack('l',struct.pack('L', 0x80102030))[0]

Thanks, that does the trick.

Scott



More information about the python-win32 mailing list