Delphi emulating microsoft RTL "srand" & "random" functions

I want to reproduce the same random numbers that the MS RTL does. To produce the same cardsets Freecell (the windows card game) does when supplying the same game numbers.

Regards Jacco
LVL 10
JaccoAsked:
Who is Participating?
 
robert_marquardtConnect With a Mentor Commented:
/* Maximum value that can be returned by the rand function. */

#define RAND_MAX 0x7fff

_CRTIMP int    __cdecl rand(void);
_CRTIMP void   __cdecl srand(unsigned int);

Try

const
  MAX_RAND = $7FFF;

procedure srand(Param1: Cardinal); cdecl;
function rand: Integer; cdecl;
0
 
robert_marquardtCommented:
The easiest way is to simply call the functions from MSVCRT.DLL.
Almost any computer should have that DLL installed.
0
 
JaccoAuthor Commented:
I have the DLL, but not the interface.
0
 
JaccoAuthor Commented:
Thanks! Will try if it works.

Regards Jacco
0
 
JaccoAuthor Commented:
It works thanks for the quick response!

Regards Jacco
0
All Courses

From novice to tech pro — start learning today.