43 lines
887 B
C++

//----------------------------------------------------------------------------
//
// Copyright (C) 2006 Intel Corporation
//
// File: MyRand.h
//
// Contents: Defines a windows based object for generating pseudo random
// numbers.
//
//----------------------------------------------------------------------------
#ifndef _MY_RAND_H
#define _MY_RAND_H
#include <windows.h>
#include <exception>
using namespace std;
// This exception is thrown if any of the windows pseudo RNG functions fail
class RandomNumberError : exception
{
public:
RandomNumberError()
{}
};
// A windows based object for generating pseudo random numbers
class MyRand
{
public:
MyRand();
~MyRand();
// return a random 32 bit number
unsigned int RandomNumber() const;
// return a random 8 bit number
unsigned char RandomByte() const;
private:
HCRYPTPROV _hCryptProv;
};
#endif