Seeding with a random number: Two things come to mind: - clockcycles, a 10 ms or 18 ms resolution counter of the number of interrupts that WinWhatever has gotten since latest boot. NB: WinNT etc al have 10 ms, Win95 et al have 18 ms resolution. - Once we're at hetting time-since-boot: The CPU's Time-Stamp-Counter is another high (...) resolution seed...
The Time-stamp counter (www-search for rdtsc will give you some hints as to how to read the thing..) could be used as a 'random' number itself... It's a 64-bits unsigned number. If you'd 'encrypt' it it makes some nice random number if you can keep your CPU 'up' under WinWhatever long enough :-) > -----Original Message----- > From: Mikael [mailto:[EMAIL PROTECTED]] > Sent: donderdag 6 februari 2003 8:39 > To: Multiple recipients of list CHIPDIR-L > Subject: c++ random number problem > > > Hello everybody > > I am designing a win32 dll in vc++ for execution under mIRC > (an irc chat > client). > The idea of the app is that when the dll is called within > irc, it prints a > message to the current channel. This is working so far. > > I want to use the stdio.h header for rand() and srand() random number > generator > and seeder along with time.h for seeding the generator. I only want to > generate > about 4 random numbers during the execution of my dll. The > problem is, when > the > dll is finished, the randomizer is (as expected) reset, so if > i execute the > dll > within a second later, i get the exact same 'random' numbers. > Becuase I am > seeding the random number generator with a 1 second > resolution I guess this > makes sense but its not suitable for my program. > > What could i do to solve the problem? > > I know keeping the dll loaded is an option and mIRC provides > a means to do > this > but I would reeeeeally like an alternative method if anyone > can think of > one! > > Can anyone maybe recomend something else I can seed the > generator with to > prevent > this problem? > > Any other suggestions welcome > > Mikael > > > -------------------------------------------------------------- > -------------- > --- > Mikael Stewart > mob: +64211887798 > icq: 34818797 > -------------------------------------------------------------- > -------------- > --- > -- > Author: Mikael > INET: [EMAIL PROTECTED] > > Fat City Network Services -- 858-538-5051 http://www.fatcity.com > San Diego, California -- Mailing list and web hosting services > --------------------------------------------------------------------- > To REMOVE yourself from this mailing list, send an E-Mail message > to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in > the message BODY, include a line containing: UNSUB CHIPDIR-L > (or the name of mailing list you want to be removed from). You may > also send the HELP command for other information (like subscribing). > > -- Author: Faasse, P.R. INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB CHIPDIR-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
