I have a C++ program that uses /dev/urandom on Unix systems to seed boost::mt19937. I'm porting the program to Windows. I can get good, random seed data on Windows similar to random seed data produced from /dev/urandom on Unix systems like so:

HCRYPTPROV hProvider = 0;
BYTE randomBytes[8];
CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
CryptGenRandom(hProvider, sizeof(randomBytes), randomBytes);   
CryptReleaseContext(hProvider, 0);

However, I'm running into trouble attempting to pass these randomBytes to boost::mt19937. On Unix I do something similar to this:

uint64_t GetSeed()
{
uint64_t seed;
std::ifstream urandom;
urandom.open("/dev/urandom");
urandom.read(reinterpret_cast<char*> (&seed), sizeof(seed));
urandom.close();
return seed;
}

boost::mt19937 rng(GetSeed());

That works OK on Unix I think. Could anyone suggest how to get the random data from the Windows CryptoAPI passed to boost::mt19937 as seed data? I don't normally program Windows systems, so this has been a bit of a challenge for me.

Thanks for any tips,

Ed