Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Saber que tipo de Drive es con un TDriveComboBox (https://www.clubdelphi.com/foros/showthread.php?t=54688)

Negriz 27-03-2008 17:07:40

Saber que tipo de Drive es con un TDriveComboBox
 
Hola, mi pregunta es como saber si el drive seleccionado en el DrivecomboBox es una unidad de Cd o un disco extrible.
que valor retorna o que propiedad uso para saber esto.

Gracias

cloayza 27-03-2008 21:31:11

Utiliza la funcion GetDriveType, debes incluir la ShellApi.

Ejemplo:

Código Delphi [-]
Var
DType: Integer;
s:String;
disco:string;
Begin
       disco:='C:\';
       DType:=GetDriveType(PChar(disco));
       case (DType) Of
             0  :s:='No puede ser determinado'
             1  :s:='No existe'
             DRIVE_REMOVABLE:s:='Removible'
             DRIVE_FIXED    :s:='Disco no removible';drive.
             DRIVE_REMOTE    :s:='Disco de red';
             DRIVE_CDROM    :s:='CD-ROM';
             DRIVE_RAMDISK  :s:='Ram disk'
       end;
       showmessage(s);
end;

Saludos desde
Concepcion-Chile

escafandra 27-03-2008 21:48:13

La API GetDriveType se maneja así: (Ayuda de Builder)


Cita:

The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.

UINT GetDriveType(
LPCTSTR lpRootPathName // address of root path
);


Parameters

lpRootPathName

Points to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory.



Return Values

The return value specifies the type of drive. It can be one of the following values:

Value Meaning
0 The drive type cannot be determined.
1 The root directory does not exist.
DRIVE_REMOVABLE The drive can be removed from the drive.
DRIVE_FIXED The disk cannot be removed from the drive.
DRIVE_REMOTE The drive is a remote (network) drive.
DRIVE_CDROM The drive is a CD-ROM drive.
DRIVE_RAMDISK The drive is a RAM disk.

Saludos.

Negriz 28-03-2008 18:14:32

Ok gracias a los dos, voy a probar.

Negriz 31-03-2008 03:08:57

hey? la manera de usarlo seria asi:

ya tengo un DriveComboBox llamado D_Drive; seria aglo asi:

AnsiString x = D_Drive->Drive;

if( ( GetDriveType( (x + "://").c_str() ) != DRIVE_CDROM )

{
...
}

asi lo puedo usar?
para la memoria usb se usa el de:
DRIVE_REMOVABLE?

gracias

escafandra 31-03-2008 10:56:37

...Pues si, así es.

Mira esto.

Saludos.

Negriz 31-03-2008 22:05:01

Gracias
 
si ya lo entendi, muchas gracias por la ayuda; lo que pasa es que tretorna un entero por cada uno de los valores que me diste:

0 The drive type cannot be determined.
1 The root directory does not exist.
2 : DRIVE_REMOVABLE The drive can be removed from the drive.
3 : DRIVE_FIXED The disk cannot be removed from the drive.
4 : DRIVE_REMOTE The drive is a remote (network) drive.
5 : DRIVE_CDROM The drive is a CD-ROM drive.
6 : DRIVE_RAMDISK The drive is a RAM disk.

muchas gracias fue muy utli.

saludos desde Colombia


La franja horaria es GMT +2. Ahora son las 12:40:27.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi