On the face of it, that looks correct to me. The only think I can think of is: how does this code get executed? I.e. when it gets run, what is it in response to? Depending on what you're responding to, you may need an application context.
Also, you should check the error results from both calls. One of them may shed some light.
Changing code like this worked for me.
AIDictKey key = sAIDictionary->Key("keyName");
I guess inline key entry creation was problem.
Inline key creation would be:
Your previous code:
Is just casting a char pointer to an AIDictKey which is why it didn't work.