Updated with changes + some improvements (OOM handling in getItem, etc). Also, I changed the key to be NUL terminated string instead of with len, because I realized the input to this are interfaces exposed to apps, and some of them are probably going to pass a normal WCHAR string instead of a BSTR, and I don't want to be the one to debug this if it's the case (although this does require special handling for NULL string, which the BSTR APIs handled transparently...)