• Welcome to Valhalla Legends Archive.
 

Why doesn't this work

Started by UserLoser, September 28, 2006, 10:22 PM

Previous topic - Next topic

UserLoser


void Registry::EnumKeys(EnumKeyCallback Callback)
{
char KeyName[MAX_KEY_LENGTH];
DWORD Size;
int Index = 0;
while(RegEnumKeyEx(hKey, Index, KeyName, &Size, NULL, NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS) {
OutputDebugString("Calling...");
OutputDebugString(KeyName);
OutputDebugString("\n");
//Callback(KeyName);
Index++;
}
}


Outputs "Calling...test" twice.  Should be test and test2.  ugh makes no sense
MAX_KEY_LENGTH = 255

Kp

#1
Perhaps the second pass returns a failure code (other than ERROR_NO_MORE_ITEMS), leading you to run the loop with stale data?

Also, you should initialize Size on each iteration.  RegEnumKeyEx reads it on startup and modifies it before returning.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

UserLoser

Ugh, not setting size was the issue.  Been working on this project too long today.. Thanks