Creating a Unique GUID

 < Day Day Up > 

Each extension is ultimately identified by a complex number called a globally unique identifier (GUID). Any extension you write will need its own GUID, and it is best to not make one up. The reasons to have GUIDs are found in the history of software development and how components such as software interact with each other and the operating system.

As computers have become more complex, the use of names to describe unique content, features, and functionalities has become problematic. Names created by independent parties who were developing these features often were identical to names from other developers. Usually, this similarity was unintended, but the results were that Windows (and applications) often got confused as to which object was being referred to because two items had the same name.

As a solution, Microsoft created a methodology to ensure that every component had a unique name that would never be duplicated under normal circumstances. These identifiers were first used with Object Linking and Embedding (OLE) to allow objects to be embedded into documents. Each object needed a global identifier that never changed for that object (even between two computers) and was unique. Enter the GUID, a system that was initially set up by Microsoft and adopted by many others along the way.

A GUID is a 16-byte (128-bit) number. In reality, a GUID is divided into groups of 8 hexadecimal digits, 4 hexadecimal digits, 4 hexadecimal digits, 4 hexadecimal digits, and 12 hexadecimal digits. Neither the value nor the position of any part of the GUID is significant nor is there any meaning for the groupings.

A GUID is generated, under optimal conditions, by taking the generating computer's Ethernet or Token Ring hardware address (the NIC MAC address, a value that in itself is unique to this one computer), the current time, and a pseudorandom number. All three are mixed together with a bit of programming magic to create a GUID. We are guaranteed that no two computers will have the same NIC MAC address. Even if there were to be two identical MAC addresses, it is very unlikely that both would try to generate a GUID at the same time or that the pseudo number portion would be the same. This makes GUIDs sufficiently unique so that we will never have duplicate GUIDs. There are GUID generators that do not use the NIC's MAC address; therefore, these GUIDs cannot be guaranteed to be unique. However, the likelihood of duplication is remote at best.

For example, Firefox's GUID is {ec8030f7-c20a-464f-9b0e-13a3a9e97384}. Usually an application does not change GUIDs unless it changes sufficiently that compatibility issues would result from it being confused with earlier versions of the same application.

GUID generators are available online. The website at http://www.hoskinson.net/webservices/guidgeneratorclient.aspx creates all the GUIDs you might ever want. However, should you not trust an outside source to generate your GUIDs, you can get your own GUID generator from Microsoft (GUIDGEN.EXE is part of Visual Basic 6's tools pack).

For the sample extension, GUIDGEN.EXE is used. Figure 16.11 shows the results of generating the GUID.

Figure 16.11. GUIDGEN can create GUIDs in four formats; we want ours in Registry Format.


The GUID shown is the one used in this chapter's example.

     < Day Day Up > 


    Firefox and Thunderbird. Beyond Browsing and Email
    Firefox and Thunderbird Garage
    ISBN: 0131870041
    EAN: 2147483647
    Year: 2003
    Pages: 245

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net