Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > API de Windows
Register FAQ Members List Calendar Guía de estilo Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10/01/2007
Roilo Roilo is offline
Miembro
 
Join Date: Nov 2005
Location: Mayarí, Cuba
Posts: 143
Poder: 21
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.
Reply With Quote
  #2  
Old 10/01/2007
Neftali [Germán.Estévez]'s Avatar
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Join Date: Jul 2004
Location: Barcelona - España
Posts: 19,449
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.
Reply With Quote
  #3  
Old 10/01/2007
seoane's Avatar
[seoane] seoane is offline
Miembro Premium
 
Join Date: Feb 2004
Location: A Coruña, España
Posts: 3,717
Poder: 26
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'));

Last edited by seoane : 10/01/2007 at 14:33.
Reply With Quote
  #4  
Old 10/01/2007
Roilo Roilo is offline
Miembro
 
Join Date: Nov 2005
Location: Mayarí, Cuba
Posts: 143
Poder: 21
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.
Reply With Quote
  #5  
Old 10/01/2007
dec's Avatar
dec dec is offline
Moderador
 
Join Date: Dec 2004
Location: Alcobendas, Madrid, España
Posts: 13,142
Poder: 36
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
Reply With Quote
  #6  
Old 10/01/2007
seoane's Avatar
[seoane] seoane is offline
Miembro Premium
 
Join Date: Feb 2004
Location: A Coruña, España
Posts: 3,717
Poder: 26
seoane Va por buen camino
Quote:
Originally Posted by 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;
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 02:17.


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
Copyright 1996-2007 Club Delphi