?
Solved

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

Posted on 2005-02-27
5
Medium Priority
?
398 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:Jacco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 13414397
The easiest way is to simply call the functions from MSVCRT.DLL.
Almost any computer should have that DLL installed.
0
 
LVL 10

Author Comment

by:Jacco
ID: 13417701
I have the DLL, but not the interface.
0
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 1000 total points
ID: 13417747
/* 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
 
LVL 10

Author Comment

by:Jacco
ID: 13417775
Thanks! Will try if it works.

Regards Jacco
0
 
LVL 10

Author Comment

by:Jacco
ID: 13417799
It works thanks for the quick response!

Regards Jacco
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question