Click to See Complete Forum and Search --> : Registry access failing sometimes


bobthe
January 22nd, 2009, 02:00 PM
I'm calling RegOpenKeyEx() followed (on ERROR_SUCCESS only) by RegQueryValueEx(). The application periodically retrieves three pre-existing key values using these calls. They always work fine when the application starts up, and they work fine for a little while, but after anywhere from 10-20 minutes all three calls suddenly start failing with ERROR_FILE_NOT_FOUND. I've verified in regedit that the key still exists, and it does. Now, the really weird part is that as soon as I open regedit, the calls start to succeed again! After closing regedit and another 10-20 minutes they will begin failing again. Even stranger, there are other registry values that are retrieved by the application that don't ever fail with this code.

One things to note, that may or may not be relevant, is that the application was set up (by developers before me) to monitor another set of unrelated registry values constantly. I believe it polls every second, maybe every 3 seconds. One thought is that Windows caches the call results and the more frequent polling of this other key is pushing the cached key results I want out of the cache but Windows still thinks it has values for them, so it just tells me it can't find it. Totally a guess, but I've encountered cache problems like this before (not registry related).

ovidiucucu
January 25th, 2009, 04:27 AM
Nobody can be sure without seeing source code, but just guess you have some forgotten RegCloseKey calls. Also take a look at RegFlushKey.

juanpast
January 25th, 2009, 04:28 AM
Perhaps if you post your code we can help you...

Regards !