EnumRegKey - infinite loop on some Win98 machine, but not others?
I need to enumerate Outlook profiles on Windows 98 machines as part of my NSIS script. I have 42 machines as an initial group I'm working with, and of the 42, I had 6 that went into an infinite loop when trying to enumerate "HKCU\Software\Microsoft\Windows Messaging Subsystem\Profiles". I can't see anything different on these machines, they all have anywhere from 1 to 7-8 Outlook profiles configured. I'm doing some testing on one of the machines and can't determine why this loops endlessly:
Machine has only one Outlook profile, "GTriplett", so beneath Profiles in the registry, that is the only key present, and should therefore be the only key EnumRegKey sees before it returns an empty string or errors out. I've added some debugging stuff (well, attempt at debugging) to the loop so I can see the condition of variables and whatnot via DetailPrint, but I'm stumped.
The NSIS loop is (debugging stuff is still in it):
--------------------------------
; First build a stack of Outlook profiles
StrCpy $1 0
StrCpy $2 0
DetailPrint "Building a list of Outlook profiles..."
loop_getprofs:
ClearErrors
DetailPrint "Var 1 is $1, now reading registry"
EnumRegKey $1 HKCU "Software\Microsoft\Windows Messaging Subsystem\Profiles" $2
IfErrors getprof_error
StrCmp $1 "" done_getprofs
Push $1
DetailPrint " $2. $1"
IntOp $2 $2 + 1
StrCpy $1 0
StrCmp $2 30 EndIt
Goto loop_getprofs
getprof_error:
DetailPrint "Ran into an error reading HKCU\Sofware\MS\WMS\Profiles at index $2"
done_getprofs:
-----------------------------------
The Details window of NSIS shows this:
----------------------------------------
Building a list of Outlook profiles...
Var 1 is 0, now reading registry
0. GTriplett
Var 1 is 0, now reading registry
1. GTriplett
Var 1 is 0, now reading registry
2. GTriplett
Var 1 is 0, now reading registry
3. GTriplett
--- snip ---
Var 1 is 0, now reading registry
28. GTriplett
Var 1 is 0, now reading registry
29. GTriplett
Completed
------------------------------------
So you can see that $2 is incrementing, and therefore EnumRegKey is being told to read an incrementing index, yet it always returns "GTriplett", and will loop infinitely on it. The majority of my machines went just fine, is this a bug in EnumRegKey, or registry corruption, or... any other ideas?
Thanks very much,
Mark