hola
quiero que mi aplicacion que he creado en visual basic 6 pueda reconocer un cd´s y solo ese cd´s como puedo hacer esto
agradesco su colaboracion
| |||
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 |
| |||
Cita: Gracias por tu colaboracion pero bueno, hice lo que me pedistes pero inserto un cd´s y aparece el identificador de ese cd´s hasta ahy esta bien, pero lo que yo quiero es que reconosca el cd´s que yo diga y solo ese, como puedo hacerlo?????
Iniciado por LeandroA 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 |
| |||
hola toma el numero de tu cd por ej 123456 y luego as un if ej: dentro del timer if serial = 123456 then msgbox "si es el cd que yo decia" else msgbox "no es el cd que yo decia" end if algo tonto no?, o lo que tu quieres que si no es el cd lo expulce me avisas la verdad no entiendo bien, si es el cd que tu dices que es lo que quieres que aga o que tienes pensado hacer y si no lo es que quieres hacer? |