September 24th, 2012, 03:57 AM
CryptUnprotectData failing when code compiled on Windows 7
I need some help regarding a strange issue with CryptUnprotectData function.
I have a C++ code that reads the database password from the registry and decrypts it using CryptUnprotectData. We have to deploy this application on a Windows 7 machine.
When I compile my code on Windows XP and run it on the test Windows 7 machine, it works absolutely fine. When I compile the same code on my laptop having Windows 7 and run it on the test Windows 7 machine, CryptUnprotectData fails with GetLastError() return '87'. If I run this application on my own laptop with Windows 7 on it, it again works fine probably because my laptop has a lot of things installed including Visual Studio and all the service packs etc.
I believe I have missed out installing some dependency on the test Windows 7 machine but I am unable to figure out what is that. What is it that's making the Windows XP compiled code running fine on the test machine and not the code that's compiled on Windows 7.
Here is the call to CryptUnprotectData in the code:
NULL, // Optional entropy
NULL, // Reserved
NULL, // Optional PromptStruct
sprintf (buff, "CryptUnprotectData Error %d", GetLastError());
Please suggest. Thanks in advance.
Click Here to Expand Forum to Full Width