Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/09/2005, 20:50
LeandroA
 
Fecha de Ingreso: abril-2005
Mensajes: 351
Antigüedad: 19 años
Puntos: 3
hola te paso una forma que es comprovando el nuemero de serial del CD,
mediante la api GetVolumeInformation
despues tu as una validacion si es o no el numero de tu cd

agrega un textbox un timer y un combobox (el codigo esta echo con otro fin despues tu adaptalo a tu nesisdad)

el codigo:

Private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Declare Function GetDriveType Lib "Kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDriveStrings Lib "Kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Type T_infoUnidad
unidad As String
numSerie As Long
End Type
Dim cantUniaddes() As T_infoUnidad
Private Sub RecuperarUnidades()
Dim strSave As String
Dim unidad As String
strSave = String(255, Chr$(0))
ret& = GetLogicalDriveStrings(255, strSave)
For keer = 1 To 100
If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
unidad = Left$(strSave, InStr(1, strSave, Chr$(0)) - 1)
If GetDriveType(unidad) = 5 Then
Combo1.AddItem unidad
End If
strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
Next keer
Combo1.Text = Combo1.List(0)
ReDim cantUniaddes(Combo1.ListCount)
For i = 1 To Combo1.ListCount
cantUniaddes(i).unidad = Combo1.List(i - 1)
GetVolumeInformation cantUniaddes(i).unidad, 255, 255, serial, 0, 0, 255, 255
cantUniaddes(i).numSerie = serial
Next
End Sub
Private Sub Timer1_Timer()
For i = 1 To Combo1.ListCount
GetVolumeInformation cantUniaddes(i).unidad, 255, 255, serial, 0, 0, 255, 255
If serial <> 0 Then
Text1 = serial
End If

Next
End Sub

Private Sub Form_Load()
RecuperarUnidades
Timer1.Interval = 1000
End Sub