A properly generated GUID distinguishes your class from all other COM classes that ever have been or will be created. I admit I was a little skeptical about this claim the first time I heard it. True, 128 is a whole lot of bits, but forever is a long, long time. Fortunately, these aren’t just any 128 bits.
GUIDs should be generated with the CoCreateGuid API function, which uses a complex algorithm to calculate a new number that is based partly on the instant when the function was called and partly on the unique network number of your machine (or on other unique characteristics of your machine if you aren’t networked). Since no else can have your machine at the exact instant you generate the GUID, it can’t be duplicated. Or at least not without cheating.
Visual Basic calls CoCreateGuid when it creates a class, an interface, or a type library. You can also create GUIDs manually using GUIDGEN (a GUI program that puts GUIDs on the clipboard) or UUIDGEN (a command line program that writes GUIDs to standard output). If worst comes to worst, you can call CoCreateGuid yourself from code. Normally, you don’t have to worry about GUIDs (in fact you don’t get to) because Visual Basic generates them for you. Which brings us to the second principle of GUIDs.