Thread: How is GUID generated?

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Arrow How is GUID generated?

    Just out of curiosity, how is a GUID generated? I know that there's guidgen.exe or whatever that does it for you, but how does it know what ID's have been taken already or not? Does it need to connect to a MS "keys taken" database or something?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    15
    It uses an algorithm, originally developed by the Open Software Foundation (now absorbed into the Open Group). It uses a combination of your MAC address of the computer or (as a later security modification) the MAC address of the ethernet/token ring card and the time of generation to guarantee universal uniqueness.
    Clashes may become a problem some time around 3040.
    There is also the possibility that two non-networked computers will generate UUIDs that would clash with each other, but since they aren't networked this tends not to be a problem.
    The API calls that generate UUIDs (UuidCreate, UuidCreateSequential and CoCreateGuid) return a value which indicates the case where the UUID is only guaranteed to be unique to the local system (because of an inability to obtain a MAC address).

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ahh, so GUID is not actually technically 100% guaranteed to be 'globally unique', even though that's what it's defined to be? That's rather quite an interesting thought
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    15
    If the machine is networked then it'll be unique for the next thousand years or so (assuming there are no bugs in the algorithm itself).
    It's unique enough, and a pretty neat solution to the problem that doesn't require any central authority, or any "ownership" (as the way the web's use of URIs to solve the same problems do).

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ah, ok. I guess that's not within my lifetime (assuming they don't come up with indefinite-lifetime pills)
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 22
    Last Post: 12-23-2008, 01:53 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. DLL generated but related import library is missing?
    By George2 in forum C Programming
    Replies: 0
    Last Post: 08-18-2006, 12:13 AM
  4. qn on Microsoft Developer Studio generated resource script
    By Raison in forum Windows Programming
    Replies: 2
    Last Post: 05-29-2004, 11:49 AM
  5. unique randomly generated numbers
    By grobe59 in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2001, 08:26 PM