Bienvenido a Tecnohackers

Tecnohackers » Programacion » Area de Programacion » Programacion a Alto Nivel. Visual Basic, Java, delphi, etc.
 » 

[VB6] Detectar la unidad del CD-ROM



Autor Tema: [VB6] Detectar la unidad del CD-ROM  (Leído 1128 veces)

Desconectado CronuX

  • Veterano
  • ***
  • Mensajes: 303
  • OllyDBG
[VB6] Detectar la unidad del CD-ROM
« en: Noviembre 16, 2009, 05:08:43 am »
Si para instalar una aplicación o ejecutar un determinado software necesitas saber si existe el CD-ROM:.

Crear un formulario con una etiqueta y escribir lo siguiente:

Código: You are not allowed to view links. Register or Login
Option Explicit

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 Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6

Function StripNulls(startStrg$) As String
Dim c%, item$
c% = 1
Do
If Mid$(startStrg$, c%, 1) = Chr$(0) Then
item$ = Mid$(startStrg$, 1, c% - 1)
startStrg$ = Mid$(startStrg$, c% + 1, Len(startStrg$))
StripNulls$ = item$
Exit Function
End If
c% = c% + 1
Loop
End Function

Private Sub Form_Load()
Dim r&, allDrives$, JustOneDrive$, pos%, DriveType&
Dim CDfound As Integer
allDrives$ = Space$(64)
r& = GetLogicalDriveStrings(Len(allDrives$), allDrives$)
allDrives$ = Left$(allDrives$, r&)
Do
pos% = InStr(allDrives$, Chr$(0))
If pos% Then
JustOneDrive$ = Left$(allDrives$, pos%)
allDrives$ = Mid$(allDrives$, pos% + 1, Len(allDrives$))
DriveType& = GetDriveType(JustOneDrive$)
If DriveType& = DRIVE_CDROM Then
CDfound% = True
Exit Do
End If
End If
Loop Until allDrives$ = "" Or DriveType& = DRIVE_CDROM
If CDfound% Then
label1.Caption = "La unidad de CD-ROM corresponde a la
unidad: " & UCase$(JustOneDrive$)
Else
label1.Caption = "Su sistema no posee CD-ROM o unidad
no encontrada."
End If
End Sub

Autor: Ponchale



Tags:
Tags:

 


SMF 2.0.19 | SMF © 2016, Simple Machines
Paginas Afiliadas
Twitter - FaceBook - Daraxblog
Designed by Smf Personal