Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 14-02-2013
chinchan chinchan is offline
Miembro
 
Registrado: abr 2006
Posts: 109
Poder: 19
chinchan Va por buen camino
Saber si hay disco en la unidad

Hola estoy haciendo una aplicación C++ Builder y necesito saber si hay un cd en la unidad CDROM. Sabéis de alguna API o de alguna manera para que se entere la aplicación hay o no hay disco en la unidad?. Muchas Gracias
Responder Con Cita
  #2  
Antiguo 14-02-2013
Avatar de juanelo
juanelo juanelo is offline
Miembro
 
Registrado: sep 2007
Posts: 1.083
Poder: 18
juanelo Va por buen camino
Que tal chinchan,
Prueba con GetVolumeInformation de la API de windows (claro pensando que el SO con el que trabajas es windows).
Te hago un paste de la ayuda de esta funcion:
The GetVolumeInformation function returns information about a file system and volume whose root directory is specified.

"BOOL GetVolumeInformation(

LPCTSTR lpRootPathName, // address of root directory of the file system
LPTSTR lpVolumeNameBuffer, // address of name of the volume
DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
LPDWORD lpVolumeSerialNumber, // address of volume serial number
LPDWORD lpMaximumComponentLength, // address of system's maximum filename length
LPDWORD lpFileSystemFlags, // address of file system flags
LPTSTR lpFileSystemNameBuffer, // address of name of file system
DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
);


Parameters

lpRootPathName

Points to a string that contains the root directory of the volume to be described. If this parameter is NULL, the root of the current directory is used. If this parameter is a UNC name, you must follow it with an additional backslash. For example, you would specify \\MyServer\MyShare as \\MyServer\MyShare\.

lpVolumeNameBuffer

Points to a buffer that receives the name of the specified volume.

nVolumeNameSize

Specifies the length, in characters, of the volume name buffer. This parameter is ignored if the volume name buffer is not supplied.

lpVolumeSerialNumber

Points to a variable that receives the volume serial number. This parameter can be NULL if the serial number is not required.

lpMaximumComponentLength

Points to a doubleword value that receives the maximum length, in characters, of a filename component supported by the specified file system. A filename component is that portion of a filename between backslashes.
The value stored in variable pointed to by *lpMaximumComponentLength is used to indicate that long names are supported by the specified file system. For example, for a FAT file system supporting long names, the function stores the value 255, rather than the previous 8.3 indicator. Long names can also be supported on systems that use the New Technology file system.

lpFileSystemFlags

Points to a doubleword that receives flags associated with the specified file system. This parameter can be any combination of the following flags, with one exception: FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually exclusive.

Value Meaning
FS_CASE_IS_PRESERVED If this flag is set, the file system preserves the case of filenames when it places a name on disk.
FS_CASE_SENSITIVE If this flag is set, the file system supports case-sensitive filenames.
FS_UNICODE_STORED_ON_DISK If this flag is set, the file system supports Unicode in filenames as they appear on disk.
FS_PERSISTENT_ACLS If this flag is set, the file system preserves and enforces ACLs. For example, NTFS preserves and enforces ACLs, and FAT does not.
FS_FILE_COMPRESSION The file system supports file-based compression.
FS_VOL_IS_COMPRESSED The specified volume is a compressed volume; for example, a DoubleSpace volume.


lpFileSystemNameBuffer

Points to a buffer that receives the name of the file system (such as FAT or NTFS).

nFileSystemNameSize

Specifies the length, in characters, of the file system name buffer. This parameter is ignored if the file system name buffer is not supplied.



Return Values

If all the requested information is retrieved, the return value is nonzero.
If not all the requested information is retrieved, the return value is zero. To get extended error information, call GetLastError.

Remarks

If you are attempting to obtain information about a floppy drive that does not have a floppy disk or a CD-ROM drive that does not have a compact disc, the system displays a message box asking the user to insert a floppy disk or a compact disc, respectively. To prevent the system from displaying this message box, call the SetErrorMode function with SEM_FAILCRITICALERRORS.
The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression. This flag comes back set on a DoubleSpace volume, for example. With volume-based compression, an entire volume is either compressed or not compressed.

The FS_FILE_COMPRESSION flag indicates whether a file system supports file-based compression. With file-based compression, individual files can be compressed or not compressed.
The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are mutually exclusive; both bits cannot come back set.
The maximum component length value, stored in the DWORD variable pointed to by lpMaximumComponentLength, is the only indicator that a volume supports longer-than-normal FAT (or other file system) file names. The file system name is not altered to indicate support for long file names.

The GetCompressedFileSize function obtains the compressed size of a file. The GetFileAttributes function can determine whether an individual file is compressed.

See Also

GetCompressedFileSize, GetFileAttributes, SetErrorMode, SetVolumeLabel
"
__________________
Ya tengo Firma!
Responder Con Cita
  #3  
Antiguo 23-02-2013
chinchan chinchan is offline
Miembro
 
Registrado: abr 2006
Posts: 109
Poder: 19
chinchan Va por buen camino
Muchas gracias, es lo que buscaba. Gracias de nuevo
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
saber si una unidad de disco es una memoria flash o memory stick compaqdavid Varios 1 06-12-2006 14:07:10
Unidad de disco walito API de Windows 5 29-11-2006 22:15:21
Carpeta o Unidad de disco?? triskel API de Windows 5 15-09-2005 17:19:27
Saber unidad de disco donde estoy marceloalegre Varios 4 12-07-2005 16:47:27
Saber unidad d disco n ordenador remoto.. Muten Firebird e Interbase 4 17-06-2004 17:59:40


La franja horaria es GMT +2. Ahora son las 00:02:59.


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