Relevant to this question: NtOpenKey fails with 0xC0000034 - how to fix this?
It's basically a perfectly good debugging question: it includes the code, it isn't too long, and the problem statement is clear. (I've already posted the answer.) The bug wasn't IMO either so obscure or so simple as to make the question useless to future viewers. The OP's attitude in the comments could be better, but that's not really a reason to close the question.
However, the API call the OP is having trouble with (part of the Windows native API) is unsupported in this context. This has drawn several objections in the comments and is probably the source of the close votes. There is a supported API which would normally be more appropriate, but it has a specific limitation (the inability to handle names with embedded nulls) and AFAIK using the native API is the only way to bypass this.
I asked a question on the old meta last year about unsupported operating systems and the consensus was that questions relating to unsupported operating systems are on-topic. By my reasoning, this should make questions related to unsupported APIs on-topic too, at least under circumstances where the equivalent supported API won't solve the problem at hand.
Thoughts?