Quote Originally Posted by Ben321 View Post
Also note that nowhere does it say that CryptGenRandom is equivalent to RtlGenRandom. In fact, common sense would say they are significantly different.
We must have different definitions of "common sense." Verification of dilettante's original statement, which is 100% correct:

On a default Windows XP and later install, CryptGenRandom calls into a function named ADVAPI32!RtlGenRandom, which does not require you load all the CryptAPI stuff.
@Steve: you are a good man to try and help a frequently aggressive forum member. The original code sample has a number of problems (you should generally always supply your own provider name, as the "default" one varies by system and is unpredictable - as you've discovered!), but if you want to continue to debug this, I'd check the value of Err.LastDllError after the initial call to CryptAcquireContext. This may have additional details.

Or you could just forgo this sample entirely, and manually request a known provider per the MSDN documentation. I think there are a number of code samples here in the forums that demonstrate this. (If not, feel free to start your own thread. You'd probably get a lot more participation from members that have learned to avoid threads from certain problematic participants.)