Hi, Can anybody tell me why this code won't work? @@: invoke RegEnumValue,TestKey,dwIndex,ADDR szValueName,\ ADDR cbValueName,NULL,NULL,NULL,NULL cmp eax,ERROR_NO_MORE_ITEMS jz @f invoke RegDeleteValue,TestKey,ADDR szValueName inc dwIndex jmp @b @@: ;cbValue name = SIZEOF szValueName+1 When I write the following values to registry: string1, string2, string3 then try to enumerate them I get and that deletes ok. then I get and finally get What happens here? It seems everytime my string is one character shorter. I going crazy trying to figure this out. Any help much appreciated, czDrillard
Posted on 2000-12-09 23:53:00 by czDrillard
Below is the quote from win32 api reference: lpcbValueName Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpValueName parameter. This size should include the terminating null character. When the function returns, the variable pointed to by lpcbValueName contains the number of characters stored in the buffer. The count returned does not include the terminating null character. As you can see, in your code, you assume the dword pointed to by cbValueName will not be modified. In reality, it is not so. The first call is successful because the buffer size is correct. After the first call, the value of the dword is the lenght of the string minus the terminating null. So in the subsequent call, RegEnumValue found out that, the buffer size is one byte less than the string it will return. The string is truncated to match the size of the buffer. No wonder your string is shorter by one byte after a call!
Posted on 2000-12-10 02:32:00 by Iczelion
Thanx Iczelion, How then can I set cbValueName to buffer length dynamically? I thought SIZEOF operator do that. I try incrementing cbValueName after each call but this only work if all my values are same size. Any help appreciated. best regards, czDrillard
Posted on 2000-12-10 12:50:00 by czDrillard