Article ID: 176790 - Last Review: August 30, 2004 - Revision: 2.2 How To Use CoCreateGUID API to Generate a GUID with VBThis article was previously published under Q176790 On This PageSUMMARY
As a programmer, you may need to generate GUIDs (Globally Unique
Identifiers) for various purposes. This article describes how to generate a
GUID in Visual Basic using the CoCreateGuid API.
NOTE: The code in this article is not intended and cannot be used to create or change a GUID automatically generated by Visual Basic for custom ActiveX components. GUIDs automatically generated by Visual Basic cannot be altered. MORE INFORMATION
The code below can be used to create a GUID in Visual Basic. The code calls
the CoCreateGuid API found in OLE32.DLL on Windows 95, Windows 98, Windows Me, Windows NT and Windows 2000. In order to call the API correctly, a variable of type GUID must be passed. This code creates a custom type, named GUID, with four
parts that represent the individual parts separated by dashes that you
would see when viewing a CLSID or GUID in the system registry. This code
simply returns a GUID; however, it can be modified to add the dashes if
desired:
Step By Step Example
APPLIES TO
| Article Translations
|
Back to the top
