It's more in line with most C code to use !memcmp(...) instead of memcmp(...)==0. I find it easier to scan, anyway, as I've gotten used to ! comparisons to check equality in memcmp, strcmp, and variants.
Another minor point: it's customary to set last error prior to testing it when you expect it to have a certain value, e.g.:
Prior to the result = CryptDecrypt(hKey, ...) line, please add a SetLastError(0xdeadbeef); that will ensure that the following comparison of GetLastError() to NTE_BAD_DATA isn't succeeding due to an earlier failure.