GUID Generation Question

This is a discussion on GUID Generation Question within the Windows Programming forums, part of the Platform Specific Boards category; I am familiar with CoCreateGUID and UUIDCreate methods of generating GUIDs. However, I was wondering if there was any technique ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    88

    GUID Generation Question

    I am familiar with CoCreateGUID and UUIDCreate methods of generating GUIDs. However, I was wondering if there was any technique for generating GUIDs where you could reproduce the results. Basically what I am looking for is a way to "seed" the GUID creation in such a way that I could reliably generate a series of GUIDs that was reproduceable after a seeding-type call was made.

    Is there any technique for accomplishing this?

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    It wouldn't be much of a GUID, would it? However, if that's what you really want you can populate the _GUID structure yourself by probably using a seeded random number generator.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    330
    Quote Originally Posted by mercury529
    I am familiar with CoCreateGUID and UUIDCreate methods of generating GUIDs. However, I was wondering if there was any technique for generating GUIDs where you could reproduce the results. Basically what I am looking for is a way to "seed" the GUID creation in such a way that I could reliably generate a series of GUIDs that was reproduceable after a seeding-type call was made.

    Is there any technique for accomplishing this?
    So you mean you want to keep the exact same GUI generation algorithm but you wanna be able to reproduce it?
    If thats the case then you should find out exactly how GUID's are generated then it should be possible to reproduce them.
    For instance, if the GUID is based on time and machinename then you should store the exact time and comp name you generated the GUID with and make the same algorithm as implemented by CoCreateGUID

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,450
    Quote Originally Posted by KIBO
    So you mean you want to keep the exact same GUI generation algorithm but you wanna be able to reproduce it?
    If thats the case then you should find out exactly how GUID's are generated then it should be possible to reproduce them.
    For instance, if the GUID is based on time and machinename then you should store the exact time and comp name you generated the GUID with and make the same algorithm as implemented by CoCreateGUID
    siplier way just to store all generated for the program guids in some text file and read them from this file as needed
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    88
    MarioF: I would not be using Microsoft's method of generating a GUID if I populated a GUID structure using random number info. The GUID I created would be an illegal GUID and could conflict with existing GUIDs.

    KIBO: As far as I know, the method for generation of GUIDs is undocumented intentionally by Microsoft as is treated as proprietary. I may be wrong on this, but I thought that was the case.

    Vart: I am currently using the technique you described. However, I want a sufficient backup in the case of file corruption to be able to retrieve the exact GUIDs I created.

    I see a few uses for being able to reproduce the same GUIDs with a seeding function. In my current case, I am trying to generate Package Codes for an MSI installer. If my file that contains the package code GUIDs for every version remains in tact, there is no problem. However, if there is an occurence where my file and its backups are corrupted, I would like to be able to produce the same string of GUIDs programmatically.

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,450
    Quote Originally Posted by mercury529
    Vart: I am currently using the technique you described. However, I want a sufficient backup in the case of file corruption to be able to retrieve the exact GUIDs I created.
    use registry
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    88
    Vart: I was hoping for a technique that as long as I had the same hardware, I would always be able to reproduce the same results. If I was forced to do a reinstall of the OS because of registry corruption (virus attack, etc), I would not want to lose the values. Although losing the backups as well is unlikely, I'd like to be as prepared as possible.

    If there is a way to seed the GUIDs, it may have use in a custom encryption design as well.

  8. #8
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,450
    Quote Originally Posted by mercury529
    Vart: I was hoping for a technique that as long as I had the same hardware, I would always be able to reproduce the same results. If I was forced to do a reinstall of the OS because of registry corruption (virus attack, etc), I would not want to lose the values. Although losing the backups as well is unlikely, I'd like to be as prepared as possible.

    If there is a way to seed the GUIDs, it may have use in a custom encryption design as well.
    If there was - it was not GUID... The main idea of the GUID - its uniqeness on any call to the generator in the near 10000 years
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  9. #9
    Registered User
    Join Date
    Nov 2005
    Posts
    88
    Well obviously in the background, as nothing is truly random, there must be an algorithm for generating the random components of the GUID. This algorithm either always generates the same "random" order of GUIDs, essentially an unseedable random number generation. Or the algorithm is in some way seedable to vary the randomness of the GUIDs it generates.

    Essentially what I am hoping to find is a technique for seeding the background random component in such a way that I can generate the same GUID in much the same way you can seed a random number generator to always produce the same string of "random" results.

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    > Although losing the backups as well is unlikely, I'd like to be as prepared as possible.
    If your backup fails to the point where this is an issue, the lack of your GUIDs will be the least of your problems.

    If you ever get into such a state, simply recreate a new consistent set of GUIDs to use with the new installation.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21