El id único que tiene tu pc y que genrealmente se utiliza como valor de semilla para generadores de números aleatorios es la dirección física de la placa de red (MAC).
Saludos.
En línea
A la reina de las profundidades que cuida los pasos de una sombra en la noche :*
'------------------------------------------------------------------ 'Clase para generar GUID (20/Abr/98) ' 'Código extraido de la Knowledge Base de Microsoft: 'HOWTO: Use CoCreateGUID API to Generate a GUID with VB 'Article ID: Q176790 '------------------------------------------------------------------ Option Explicit
Private Type GUID Data1 As Long Data2 As Integer Data3 As Integer Data4(0 To 7) As Byte End Type
Private Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As Long
Const S_OK = 0 ' return value from CoCreateGuid
Public Function GetGUID() As String
Dim lResult As Long Dim lguid As GUID Dim MyguidString As String Dim MyGuidString1 As String Dim MyGuidString2 As String Dim MyGuidString3 As String Dim DataLen As Integer Dim StringLen As Integer Dim i As Integer
On Error GoTo error_olemsg
lResult = CoCreateGuid(lguid) If lResult = S_OK Then MyGuidString1 = Hex$(lguid.Data1) StringLen = Len(MyGuidString1) DataLen = Len(lguid.Data1) MyGuidString1 = LeadingZeros(2 * DataLen, StringLen) & MyGuidString1 'First 4 bytes (8 hex digits) MyGuidString2 = Hex$(lguid.Data2) StringLen = Len(MyGuidString2) DataLen = Len(lguid.Data2) MyGuidString2 = LeadingZeros(2 * DataLen, StringLen) & Trim$(MyGuidString2) 'Next 2 bytes (4 hex digits) MyGuidString3 = Hex$(lguid.Data3) StringLen = Len(MyGuidString3) DataLen = Len(lguid.Data3) MyGuidString3 = LeadingZeros(2 * DataLen, StringLen) & Trim$(MyGuidString3) 'Next 2 bytes (4 hex digits) MyguidString = MyGuidString1 & "-" & MyGuidString2 & "-" & MyGuidString3 & "-" For i = 0 To 7 MyguidString = MyguidString & Format$(Hex$(lguid.Data4(i)), "00") Next 'MyGuidString contains last 8 bytes of Guid (16 hex digits) GetGUID = MyguidString Else GetGUID = "00000000-0000-0000-0000000000000000" ' return zeros if function unsuccessful End If Exit Function
error_olemsg: MsgBox "Error " & Str(Err) & ": " & Error$(Err) GetGUID = "00000000-0000-0000-0000000000000000" Exit Function End Function
Private Function LeadingZeros(ExpectedLen As Integer, ActualLen As Integer) As String LeadingZeros = String$(ExpectedLen - ActualLen, "0") End Function
Private Sub Command1_Click() 'Creamos una instancia de la clase ' Dim tGuid As GUID
'Asignamos el número generado, en este ejemplo lo asignamos a un Label Label1 = GetGUID 'Destruimos la referencia al objeto 'Set tGuid = Nothing End Sub