Home > Back-end > The only serial number generation problems is not connected to the case
The only serial number generation problems is not connected to the case
Time:04-30
Produced a string of with the serial number of the uniqueness, randomly generated to take time, random is actually the seeds of time, but in the case of not connected to the Internet, RTC the initialization of the same circumstances, delivery time should be for the board is the same, the random serial number is the only? If not, how to ensure that the serial number that the only?
CodePudding user response:
Time is accurate to seconds, in time for the seeds, then can guarantee each serial number of the seeds are all the same time?
CodePudding user response:
# pragma comment (lib, "ole32") #include #include The union U { GUID GUID. Unsigned char b [16]. } u; int i; Char s [33]; Void main () { If (S_OK!=CoCreateGuid (& amp; U.g uid)) return; for (i=0; i<16. I++) sprintf (s + I * 2, "x % 02," u.b [I]); Printf (" GUID=% s \ n ", s);//every result is not the same as } //GUID=f5a44443aa5fb1479bf6741fa213d33c