#include <windows.h>
#include <time.h>

typedef void (*INIT_GEN_RND)(unsigned long);
typedef unsigned long (*GEN_RND_INT32)(void);
typedef double (*GEN_RND_REAL2)(void);

#define DLLNAME "mt19937ar-cok.dll"


int main(int argc, char **argv)
{
  HINSTANCE   hInstDLL;
  INIT_GEN_RND  InitGenRnd;
  GEN_RND_INT32 GenRndInt32;
  GEN_RND_REAL2 GenRndReal2;
  time_t  t;
  
  if((hInstDLL=LoadLibrary(DLLNAME))==NULL)
    abort();

  t=time(NULL);
  InitGenRnd=(INIT_GEN_RND)GetProcAddress(hInstDLL,"init_genrand");
  InitGenRnd(t);

  GenRndInt32=(GEN_RND_INT32)GetProcAddress(hInstDLL,"genrand_int32");
  printf("%lu\n",GenRndInt32());
  printf("%lu\n",GenRndInt32());
  printf("%lu\n",GenRndInt32());
  printf("%lu\n",GenRndInt32());
  printf("%lu\n",GenRndInt32());

  GenRndReal2=(GEN_RND_REAL2)GetProcAddress(hInstDLL,"genrand_real2");
  printf("%f\n",GenRndReal2());
  printf("%f\n",GenRndReal2());
  printf("%f\n",GenRndReal2());
  printf("%f\n",GenRndReal2());
  printf("%f\n",GenRndReal2());

  if(!FreeLibrary(hInstDLL))
    abort();

  return  EXIT_SUCCESS;
}
