Looking at the code, which I haven't for a LONG time and was originally written in Delphi in 1995(!) then converted by someone else in 2004, it compares the string to a list of key names, but it only compares based on the length of the string passed in, so {ap}, {app}, {apps} would all match since:
//KeyNames[Middle].keyName - "APPS"
LPCTSTR KeyString; //"ap"
_tcsnicmp(KeyNames[Middle].keyName, KeyString, _tcslen(KeyString)) == 0
It's only comparing the first two letters, the length of "ap"