Are we getting an error when you try to compile? If so then what might that error be?
What version of Windows are you running this on? Might UAC or Registry Virtualization be the cause of your problem?
Some of these registry keys are only read when the system starts up. Have you tried to reboot?
You seem to be testing the return values for success but you're not making any calls to "FormatMessage()" to resolve any error codes on failure, why is that?