시디롬 의 유형 을 구분 할 수 있 습 니까?예 를 들 면 CDROM, DVD 아니면 CD - RW.
6186 단어 ROM
typedef struct _SCSI_PASS_THROUGH
{
USHORT Length;
UCHAR ScsiStatus;
UCHAR PathId;
UCHAR TargetId;
UCHAR Lun;
UCHAR CdbLength;
UCHAR SenseInfoLength;
UCHAR DataIn;
ULONG DataTransferLength;
ULONG TimeOutValue;
ULONG_PTR DataBufferOffset;
ULONG SenseInfoOffset;
UCHAR Cdb[ 16 ];
} SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;
typedef struct _SCSI_PASS_THROUGH_WITH_BUFFERS
{
SCSI_PASS_THROUGH Spt;
ULONG Filler;
UCHAR SenseBuf[ 32 ];
UCHAR DataBuf[ 512 ];
} SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS;
//
//
BOOL CanWrite( HANDLE hDevice ) // hDevice( )
{
SCSI_PASS_THROUGH_WITH_BUFFERS sptwb;
UCHAR CDReader, CDwriter, DVDReader, DVDwriter;
ULONG returned = 0;
ZeroMemory( &sptwb, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS) );
sptwb.Spt.Length = sizeof(SCSI_PASS_THROUGH);
sptwb.Spt.PathId = 0;
sptwb.Spt.TargetId = 1;
sptwb.Spt.Lun = 0;
sptwb.Spt.CdbLength = 6;
sptwb.Spt.SenseInfoLength = 24;
sptwb.Spt.DataIn = 1;
sptwb.Spt.DataTransferLength = 192;
sptwb.Spt.TimeOutValue = 2;
sptwb.Spt.DataBufferOffset = offsetof( SCSI_PASS_THROUGH_WITH_BUFFERS,
DataBuf );
sptwb.Spt.SenseInfoOffset = offsetof( SCSI_PASS_THROUGH_WITH_BUFFERS,
SenseBuf );
sptwb.Spt.Cdb[ 0 ] = 0x1A;
sptwb.Spt.Cdb[ 1 ] = 0x08;
sptwb.Spt.Cdb[ 2 ] = 0x2A;
sptwb.Spt.Cdb[ 4 ] = 192;
ULONG length = offsetof( SCSI_PASS_THROUGH_WITH_BUFFERS, DataBuf )
+ sptwb.Spt.DataTransferLength;
BOOL status = DeviceIoControl( hDevice, IOCTL_SCSI_PASS_THROUGH, &sptwb,
sizeof(SCSI_PASS_THROUGH), &sptwb, length, &returned, FALSE );
if ( !status )
{
return false;
}
if ( sptwb.Spt.ScsiStatus )
{
return false;
}
else
{
if ( CDwriter = ( ( sptwb.DataBuf[ 7 ] & 0x01 )
|| ( sptwb.DataBuf[ 7 ] & 0x02 ) ) )
{
return true;
}
if ( DVDwriter = ( ( sptwb.DataBuf[ 7 ] & 0x10 )
|| ( sptwb.DataBuf[ 7 ] & 0x20 ) ) )
{
return true;
}
}
return false;
}