Jason Meridth

I am a continuously learning senior full stack SDE/SRE trying to not let best be the enemy of better.

Buy me a coffeeBuy me a coffee

RegOpenKeyEx Function and LOL

13 Oct 2008 » »

I am currently interacting with 64 bit registry entries from a 32-bit application so I’m having to resort to DllImports.  Fun fun.

I came across this line in the MSDN entry of RegOpenKeyEx:

A single registry key can be opened only 65534 times. When attempting the 65535th open operation, this function fails with ERROR_NO_SYSTEM_RESOURCES.
(In the Remarks section of here)

Just thought it was funny.

What’s not funny, is that I’m having to write this code in .NET 1.1 due to clients not willing to upgrade their servers to at least .NET 2.0.  The horror.

Side Note:  I have 2 posts coming.  One on using Microsoft Sandcastle to automate chm generation from API code (where comments are acceptable in my code) and another on MSI generation using WiX.  Coming soon.

Comments

Thomas Nguyen: I’m new to C# Applications and its best practices. I’ve got a bunch of bumps and bruises trying to figure out all the magic, including DllImport. There’s so much out there on web-dev and I’m wondering if you have any books/articles that would help me with Windows Applications (best practices, (un)installers, etc.). Thanks!

Jason Meridth: 1. Pragmatic Programmer 2. C# 2008 and the .Net 3.5 platform by Andrew Troelson Awesome books

Marcus Bratton: I’d really rather think it should fail with WTF_ARE_YOU_DOING. Makes more sense to me. ;)