Wednesday, September 22, 2004

Doh!

I've just wasted an hour solving a small problem. The app uses a local path and a remote path - both these are stored in the registry and read on the fly as needed. I needed to activate the remote path (there's logic to test if the remote path exists - if not we use the local path). So I created the necessary key and set the path and... nothing! The app used the local path. So I fired up the debugger and traced the code. Sure enough, when the app tried to retrieve the remote path it came back with nothing and used the local path. Tracing into the Win32 call that reads the remote path it was returning PATH NOT FOUND for the remote path key but finding the local path key just fine. But they're both there! A careful check of the spelling of the keyname - they match. Delete the key and recreate it using cut and paste to copy the keyname from the source code to the registry. Still not found!

So then I tried a different approach. I could read the local path entry but not the remote path entry. Ok, so I changed the local path entry to a different value and traced again. It didn't change. By this time I'm scratching my head. So it's off to the MSDN Knowledge base for anything about registry value caching. Nothing useful popped up. And then....

My eye wandered a branch or two above the branch I had been looking at, in regedit. And there were TWO registry branches for my apps key.

It turns out that the guy who wrote this code (I've inherited it) had made a copy of our products registry tree, appending a dot to the name. And you guessed it, I'd been making all my changes in the copy.

Doh!!!!

No comments: