Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-01-2007
Roilo Roilo is offline
Miembro
 
Registrado: nov 2005
Ubicación: Mayarí, Cuba
Posts: 143
Poder: 19
Roilo Va por buen camino
Smile CD-ROM o CD-RW o DVD ....

Saludos al FORO.
FELICIDADES por este nuevo año.
Me preguntaba si conocen alguna forma de determinar si la torre de CD instalada en un equipo es RW o DVD o simplemente CD-R...
GRACIAS.
Responder Con Cita
  #2  
Antiguo 10-01-2007
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.285
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
¿Has revisado componentes de información sobre el hardware de la máquina?
Estoy seguro que no deben tener problemas para saber el tipo de la unidad.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #3  
Antiguo 10-01-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Este ejemplo esta basado en este otro de microsoft:

http://support.microsoft.com/kb/305184

Código Delphi [-]
const
  SPT_SENSE_LENGTH = 32;
  SPTWB_DATA_LENGTH = 512;

  CDB6GENERIC_LENGTH = 6;
  SCSI_IOCTL_DATA_IN = 1;
  SCSIOP_INQUIRY = $12;
  SCSIOP_MODE_SENSE = $1A;
  MODE_PAGE_CAPABILITIES = $2A;
  IOCTL_SCSI_PASS_THROUGH = $04D004;

type
  ULONG_PTR = ULONG;

  SCSI_PASS_THROUGH = record
    Length: Word;
    ScsiStatus: UCHAR;
    PathId: UCHAR;
    TargetId: UCHAR;
    Lun: UCHAR;
    CdbLength: UCHAR;
    SenseInfoLength: UCHAR;
    DataIn: UCHAR;
    DataTransferLength: ULONG;
    TimeOutValue: ULONG;
    DataBufferOffset: ULONG_PTR;
    SenseInfoOffset: ULONG;
    Cdb: array[0..15] of UCHAR;
  end;
  PSCSI_PASS_THROUGH = ^SCSI_PASS_THROUGH;

  SCSI_PASS_THROUGH_WITH_BUFFERS = record
    spt: SCSI_PASS_THROUGH;
    Filler: ULONG;
    ucSenseBuf: array[0..SPT_SENSE_LENGTH-1] of UCHAR;
    ucDataBuf: array[0..SPTWB_DATA_LENGTH-1]of UCHAR;
  end;
  PSCSI_PASS_THROUGH_WITH_BUFFERS = ^SCSI_PASS_THROUGH_WITH_BUFFERS;

function offsetof(a,b: Pointer): integer;
begin
  Result:= Integer(b) - Integer(a);
end;

function BoolToSiNo(Value: Boolean): String;
begin
  if Value then
    Result:= 'Si'
  else
    Result:= 'No';
end;

function GetDeviceProperty(Letra: Char): string;
var
  Disk: THandle;
  Sptwb: SCSI_PASS_THROUGH_WITH_BUFFERS;
  l: ULONG;
  Returned: Cardinal;
begin
  Result:= EmptyStr;
  Disk:= CreateFile(PChar('\\.\' + Letra + ':'),GENERIC_READ or GENERIC_WRITE,
    FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
    
  if Disk <> INVALID_HANDLE_VALUE then
  begin
    FillChar(Sptwb,Sizeof(Sptwb),0);
    Sptwb.Spt.Length:= sizeof(SCSI_PASS_THROUGH);
    Sptwb.Spt.PathId:= 0;
    Sptwb.Spt.TargetId:= 1;
    Sptwb.Spt.Lun:= 0;
    Sptwb.Spt.CdbLength:= CDB6GENERIC_LENGTH;
    Sptwb.Spt.SenseInfoLength:= 24;
    Sptwb.Spt.DataIn:= SCSI_IOCTL_DATA_IN;
    Sptwb.Spt.DataTransferLength:= 192;
    Sptwb.Spt.TimeOutValue:= 2;
    Sptwb.Spt.DataBufferOffset:=
       offsetof(@Sptwb,@Sptwb.ucDataBuf);
    Sptwb.Spt.SenseInfoOffset:=
       offsetof(@Sptwb,@Sptwb.ucSenseBuf);
    Sptwb.Spt.Cdb[0]:= SCSIOP_MODE_SENSE;
    Sptwb.Spt.Cdb[1]:= $08;
    Sptwb.Spt.Cdb[2]:= MODE_PAGE_CAPABILITIES;
    Sptwb.Spt.Cdb[4]:= 192;

    l:= offsetof(@Sptwb,@Sptwb.ucDataBuf) +
       sptwb.Spt.DataTransferLength;

    if DeviceIoControl(Disk,IOCTL_SCSI_PASS_THROUGH,@Sptwb,
      Sizeof(SCSI_PASS_THROUGH),@sptwb,l,Returned,nil) then
    begin
       if ((Sptwb.ucDataBuf[6] and $01) or (Sptwb.ucDataBuf[6] and $02) > 0) then
       begin
         Result:= 'CD Reader: Si';
         Result:= Result + #13#10 + 'CD-R: ' + BoolToSiNo((Sptwb.ucDataBuf[6] and $01)>0);
         Result:= Result + #13#10 + 'CD-RW: ' + BoolToSiNo((Sptwb.ucDataBuf[6] and $02)>0);
         if (Sptwb.ucDataBuf[7] and $01) or (Sptwb.ucDataBuf[7] and $02) > 0 then
         begin
           Result:= Result + #13#10#13#10 + 'CD Writer: Si';
           Result:= Result + #13#10 + 'CD-R: ' + BoolToSiNo((Sptwb.ucDataBuf[7] and $01)>0);
           Result:= Result + #13#10 + 'CD-RW: ' + BoolToSiNo((Sptwb.ucDataBuf[7] and $02)>0);
         end else Result:= Result + #13#10#13#10 + 'CD Writer: No';
       end else Result:= 'CD Reader: No';

       if (Sptwb.ucDataBuf[6] and $08) or (Sptwb.ucDataBuf[6] and $10) or
         (Sptwb.ucDataBuf[6] and $20) > 0 then
       begin
         Result:= Result + #13#10#13#10 + 'DVD Reader: Si';
         Result:= Result + #13#10 + 'DVD-ROM: ' + BoolToSiNo((Sptwb.ucDataBuf[6] and $08)>0);
         Result:= Result + #13#10 + 'DVD-R: ' + BoolToSiNo((Sptwb.ucDataBuf[6] and $10)>0);
         Result:= Result + #13#10 + 'DVD-RAM: ' + BoolToSiNo((Sptwb.ucDataBuf[6] and $20)>0);
         if ((Sptwb.ucDataBuf[7] and $10) or (Sptwb.ucDataBuf[7] and $20) > 0) then
         begin
           Result:= Result + #13#10#13#10 + 'DVD Writer: Si';
           Result:= Result + #13#10 + 'DVD-R: ' + BoolToSiNo((Sptwb.ucDataBuf[7] and $10)>0);
           Result:= Result + #13#10 + 'DVD-RAM: ' + BoolToSiNo((Sptwb.ucDataBuf[7] and $20)>0);
         end else Result:= Result + #13#10#13#10 + 'DVD Writer: No';
       end else Result:= Result + #13#10#13#10 + 'DVD Reader: No';
    end else Result:= SysErrormessage(GetLastError);
    CloseHandle(Disk);
  end else Result:= SysErrormessage(GetLastError);
end;

// Por ejemplo
ShowMessage(GetDeviceProperty('d'));

Última edición por seoane fecha: 10-01-2007 a las 14:33:53.
Responder Con Cita
  #4  
Antiguo 10-01-2007
Roilo Roilo is offline
Miembro
 
Registrado: nov 2005
Ubicación: Mayarí, Cuba
Posts: 143
Poder: 19
Roilo Va por buen camino
Gracias

Me gusta ese inicio, pero ahora tengo otra.
ese parámetro que le damos a la función GetDeviceProperty, que se trata nada más y nada menos que de la unidad de disco, está fijo, y no en todas las máquinas la torre de discos está en 'd'. Yo encontré una función que me devuelve la letra de la unidad del disco, pero me la devuelve de tipo string y el parámetro que le pasamos a la funcióm GetDeviceProperty es de tipo char. Me pregunto si conoces algun STRTOCHAR o algo parecido...
GRACIAS.
Responder Con Cita
  #5  
Antiguo 10-01-2007
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Código Delphi [-]
var
  s: string;
begin
  {...}
  GetDeviceProperty( PChar(s) );
end;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #6  
Antiguo 10-01-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Cita:
Empezado por dec
GetDeviceProperty( PChar(s) );

Jeje, muy ingenioso dec aunque yo añadiria
Código Delphi [-]
  GetDeviceProperty( PChar(s)^ );

Otra forma de hacerlo:
Código Delphi [-]
  if Length(s) > 0 then
    GetDeviceProperty( s[1] );

y la que yo usaria:
Código Delphi [-]
var
  Letra: Char;
begin
  for Letra:= 'A' to 'Z' do
    if GetDriveType(Pchar(Letra+':\')) = DRIVE_CDROM  then
    begin
       ShowMessage(GetDeviceProperty(Letra));
    end;
end;
Responder Con Cita
  #7  
Antiguo 10-01-2007
Roilo Roilo is offline
Miembro
 
Registrado: nov 2005
Ubicación: Mayarí, Cuba
Posts: 143
Poder: 19
Roilo Va por buen camino
Ideal...

Les agradesco de nuevo, todo ha salido como agua.
Neftali, cuáles componentes son esos que te brinda información sobre la máquina y donde los puedo encontrar.
GRACIAS.
Responder Con Cita
  #8  
Antiguo 10-01-2007
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.285
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por Roilo
Neftali, cuáles componentes son esos que te brinda información sobre la máquina y donde los puedo encontrar.
Aquí puedes encontrar unos cuantos, y si buscas por internet te aparecerán muchos más...
Personalmente he revisado el de MiTEC y es muy bueno; No se cómo se distribuye ahora, pero en versiones antiguas era gratuíto.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #9  
Antiguo 11-01-2007
Roilo Roilo is offline
Miembro
 
Registrado: nov 2005
Ubicación: Mayarí, Cuba
Posts: 143
Poder: 19
Roilo Va por buen camino
Gracias...

Muy valiosos sus aportes...
Hasta Luego.
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


La franja horaria es GMT +2. Ahora son las 23:58:56.


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