Option Explicit
Private Type GUID
Data1 As Long
Data2 As Long
Data3 As Long
Data4(7) As Byte
End Type
Private Declare Function CoCreateGuid Lib "ole32.dll" (pguid As GUID) As Long
Private Declare Function StringFromGUID2 Lib "ole32.dll" (rguid As GUID, lpsz As Any, ByVal cchMax As Long) As Long
Private Sub Command1_Click()
Text1 = NewGUID
Clipboard.Clear
Clipboard.SetText Text1
MsgBox "La clef a été copié dans le presse papier", vbInformation
End Sub
Private Function NewGUID() As String
Dim mGUIDs(77) As Byte
Dim mGuid As GUID
If (CoCreateGuid(mGuid) = 0) Then
If (StringFromGUID2(mGuid, mGUIDs(0), 78)) Then
NewGUID = mGUIDs
End If
End If
End Function