I just checked this on my Office version, and can see that this routine will no longer work. It seems that things have moved under the LastKnownC2RProductReleaseId key, which lists all individual apps with their O365 names... I just haven't had the time to work out how to extract those registry values as they are different then the ones listed above.