![]() |
|
|
| Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site | ||
|
|
Generating GUIDs for Documents stored in the Exchange 2000 Web Storage System Try the following sample code to generate globally unique identifiers (GUIDs) for documents stored in the Web Storage System. I hope these samples provide helpful insights. Please feel free to email me at kzhang@outlookexchange.com if you have any comments, questions, ideas, or suggestions. Example Type GUID Data1 As Long Data2 As Integer Data3 As Integer Data4(7) As Byte End Type Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As Long Function LeadingZeros(ExpLen As Integer, ActualLen As Integer) As String LeadingZeros = String$(ExpLen - ActualLen, "0") End Function Public Function GetGUID() As String On Error GoTo Err_Here Dim lngResult As Long Dim varGUID As GUID Dim strGUID As String Dim strGUID1 As String Dim strGUID2 As String Dim strGUID3 As String Dim DataLen As Integer Dim StringLen As Integer Dim i% lngResult = CoCreateGuid(varGUID) If lngResult = 0 Then strGUID1 = Hex$(varGUID.Data1) StringLen = Len(strGUID1) DataLen = Len(varGUID.Data1) strGUID1 = LeadingZeros(2 * DataLen, StringLen) & strGUID1 & "-" strGUID2 = Hex$(varGUID.Data2) StringLen = Len(strGUID2) DataLen = Len(varGUID.Data2) strGUID2 = LeadingZeros(2 * DataLen, StringLen) & Trim$(strGUID2) & "-" strGUID3 = Hex$(varGUID.Data3) StringLen = Len(strGUID3) DataLen = Len(varGUID.Data3) strGUID3 = LeadingZeros(2 * DataLen, StringLen) & Trim$(strGUID3) & "-" GetGUID = strGUID1 & strGUID2 & strGUID3 For i% = 0 To 7 strGUID = strGUID & Format$(Hex$(varGUID.Data4(i%)), "00") Next i% GetGUID = "{" & GetGUID & strGUID & "}" Else GetGUID = "00000000" End If Exit_Here: Exit Function Err_Here: GetGUID = "00000000" GoTo Exit_Here End Function
|
Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Stephen Bryant or Pro Exchange. OutlookExchange.Com, Stephen Bryant and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
Copyright Stephen Bryant 2008