A few more twists. This exact same script code worked fine when compiled with a version of NSIS prior to 2.39 (not sure exactly which version), but now fails with the latest version 2.45. Also, this is failing on Vista, but working on XP (again, used to work on both Vista and XP with a prior NSIS version). Note that I do use "RequestExecutionLevel admin" in my script, so I don't believe it's a elevation level issue. Lastly, I copied/pasted out the problem area of my script and created a test script. That test script works fine.
Here is a snippet of the code:
; Must first remove the deny permission on Globals.
AccessControl::GrantOnRegKey HKLM "Software\SoftwareTime\ComputerTime\Globals" "(S-1-5-32-545)" "EnumerateSubKeys"
ClearErrors
DeleteRegKey HKLM "Software\SoftwareTime\ComputerTime"
${If} ${Errors}
MessageBox MB_OK "Error removing registry key."
${EndIf}