Advertisement
2002C Miscellaneous #15733

create GUID

This program creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.The idea of a GUID is that no two machines can ever generate the same GUID value twice. This is achieved by using a combination of the current time, your machine's Media Access Control (MAC) address (a unique number built into all network cards) if it has one, and other routines.

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
Private Sub Form_Load()
  MsgBox "Generated GUID: " + CreateGUID
End Sub
Public Function CreateGUID() As String
  Dim id(0 To 15) As Byte
  Dim Cnt As Long, GUID As String
  If CoCreateGuid(id(0)) = 0 Then
    For Cnt = 0 To 15
      CreateGUID = CreateGUID + IIf(id(Cnt) < 16, "0", "") + Hex$(id(Cnt))
    Next Cnt
    CreateGUID = Left$(CreateGUID, 8) + "-" + Mid$(CreateGUID, 9, 4) + "-" + Mid$(CreateGUID, 13, 4) + "-" + Mid$(CreateGUID, 17, 4) + "-" + Right$(CreateGUID, 12)
  Else
    MsgBox "Error while creating GUID!"
  End If
End Function
원본 댓글 (3)
Wayback Machine에서 복구됨