[PATCH] win32: advapi32.RegGetValue() is not available on WinXP 32-bits
Adrian Buehlmann
adrian at cadifra.com
Sat Feb 12 23:30:24 UTC 2011
On 2011-02-13 00:00, Patrick Mézard wrote:
> Le 12/02/11 23:54, Adrian Buehlmann a écrit :
>> On 2011-02-12 20:16, Patrick Mezard wrote:
>>> # HG changeset patch
>>> # User Patrick Mezard <pmezard at gmail.com>
>>> # Date 1297538010 -3600
>>> # Node ID bf513d50d7d083432db132eb876423992a3a84ec
>>> # Parent 43e44df7c2e252e876f0347a8932e1513a7331ad
>>> win32: advapi32.RegGetValue() is not available on WinXP 32-bits
>>>
>>> See:
>>>
>>> http://msdn.microsoft.com/en-us/library/ms724868(VS.85).aspx
>>>
>>> Replace it with RegQueryValueEx:
>>>
>>> http://msdn.microsoft.com/en-us/library/ms724911(v=vs.85).aspx
>>>
>>
>> Nice catch.
>>
>> I've "unit tested" all functions by manually calling them from the
>> Python 2.6.6 x64 command line interpreter on Windows 7 x64. Which
>> explains why I didn't cover this bug.
>>
>> I also watched the file access with my fsdebug extension
>> (https://bitbucket.org/abuehl/fsdebug), exercising various hardlinked
>> clone scenarios.
>>
>> I installed the complete msi on Win XP x86 but did only some basic
>> manual tests there by calling the hg command line. These didn't touch
>> this bug, because the official installer does not depend on registry
>> settings for finding the default install settings.
>>
>>> diff -r 43e44df7c2e2 -r bf513d50d7d0 mercurial/win32.py
>>> --- a/mercurial/win32.py Tue Feb 08 00:38:42 2011 +0100
>>> +++ b/mercurial/win32.py Sat Feb 12 20:13:30 2011 +0100
>>> @@ -198,8 +198,8 @@
>>> size = _DWORD(600)
>>> type = _DWORD()
>>> buf = ctypes.create_string_buffer(size.value + 1)
>>> - res = adv.RegGetValueA(kh.value, None, valname, _RRF_RT_ANY,
>>> - byref(type), byref(buf), byref(size))
>>
>> The definition of _RRF_RT_ANY (in the same file) can probably be removed
>>
>>> + res = adv.RegQueryValueExA(kh.value, valname, 0,
>>> + byref(type), buf, byref(size))
>>
>> Typically, they use None for NULL in the ctypes examples, but I guess 0
>> for lpReserved should work fine.
>
> I borrowed it from what I could find by googling ctypes and RegGetValueA.
>
>>> if res != _ERROR_SUCCESS:
>>> continue
>>> if type.value == _REG_SZ:
>
> Feel free to edit and merge the patch, you have much more experience than I have with ctypes by now.
Your patch should work as is.
More information about the Mercurial-devel
mailing list