Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
|
Re: CD Medien erkennen
29. Sep 2004, 10:27
Ich habe dir das noch mal rauskopiert dann musst du dich da nicht durchwühlen:
Der Config Head:
Delphi-Quellcode:
type
TDeviceConfigHeader = packed record
DataLength : Cardinal;
Reserved : Word;
CurrentProfile : Word;
FeatureCode : Word;
Version : Byte;
AdditionalLength : Byte;
OtherData : Array[0..101] of Byte;
end;
SPTI Command Structure:
Delphi-Quellcode:
type
PSCSI_PASS_THROUGH = ^SCSI_PASS_THROUGH;
SCSI_PASS_THROUGH = Record
Length : Word;
ScsiStatus : Byte;
PathId : Byte;
TargetId : Byte;
Lun : Byte;
CdbLength : Byte;
SenseInfoLength : Byte;
DataIn : Byte;
DataTransferLength : ULONG;
TimeOutValue : ULONG;
DataBufferOffset : ULONG;
SenseInfoOffset : ULONG;
Cdb : Array[0..15] of Byte;
end;
type
PSCSI_PASS_THROUGH_DIRECT = ^SCSI_PASS_THROUGH_DIRECT;
SCSI_PASS_THROUGH_DIRECT = record
Length : Word;
ScsiStatus : Byte;
PathId : Byte;
TargetId : Byte;
Lun : Byte;
CdbLength : Byte;
SenseInfoLength : Byte;
DataIn : Byte;
DataTransferLength : ULONG;
TimeOutValue : ULONG;
DataBuffer : Pointer;
SenseInfoOffset : ULONG;
Cdb : Array[0..15] of Byte;
end;
type
PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER = ^SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER = record
Spt : SCSI_PASS_THROUGH_DIRECT;
Filler : ULONG;
SenseBuf : Array[0..31] of Byte;
end;
Laufwerk öffnen / schließen:
Delphi-Quellcode:
function OpenDrive(Const ADrive: Char): THandle;
begin
Result := CreateFile( PChar('\\.\'+ ADrive +':'),
GENERIC_READ Or GENERIC_WRITE,
FILE_SHARE_READ Or FILE_SHARE_WRITE,
Nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
end;
function CloseDrive(Const AHandle: THandle):Boolean;
begin
Result := CloseHandle(AHandle);
end;
Die Funktion selber:
Delphi-Quellcode:
function GetDiscType(const AHandle:THandle):Integer;
var
SPTDW : SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
Size, Returned : LongWord;
DeviceConfigHeader : TDeviceConfigHeader;
begin
Result := -1;
ZeroMemory(@SPTDW, SizeOf(SPTDW));
Size := SizeOf(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
SPTDW.Spt.Length := SizeOf(SCSI_PASS_THROUGH);
SPTDW.Spt.CdbLength := 10;
SPTDW.Spt.SenseInfoLength := 32;
SPTDW.Spt.DataIn := 1; //SCSI_IOCTL_DATA_IN;
SPTDW.Spt.DataTransferLength := SizeOf(DeviceConfigHeader);
SPTDW.Spt.TimeOutValue := 120;
SPTDW.Spt.DataBuffer := @DeviceConfigHeader;
SPTDW.Spt.SenseInfoOffset := 48;
SPTDW.Spt.Cdb[0] := $46;
SPTDW.Spt.Cdb[1] := $02;
SPTDW.Spt.Cdb[3] := $00;
SPTDW.Spt.Cdb[7] := HiByte(SizeOf(DeviceConfigHeader));
SPTDW.Spt.Cdb[8] := LoByte(SizeOf(DeviceConfigHeader));
(*
if DeviceIoControl( AHandle, IOCTL_SCSI_PASS_THROUGH_DIRECT,
@SPTDW, Size, @SPTDW, Size, Returned, Nil) then
*)
if DeviceIoControl( AHandle, $4D014, @SPTDW, Size, @SPTDW, Size, Returned, Nil) then
begin
case ((( DeviceConfigHeader.CurrentProfile shl 8) and $FF00) or
(( DeviceConfigHeader.CurrentProfile shr 8) and $00FF)) of
$0000 : Result := 0;
$0001 : Result := 1;
$0002 : Result := 2;
$0003 : Result := 3;
$0004 : Result := 4;
$0005 : Result := 5;
$0008 : Result := 6;
$0009 : Result := 7;
$000A : Result := 8;
$0010 : Result := 9;
$0011 : Result := 10;
$0012 : Result := 11;
$0013 : Result := 12;
$0014 : Result := 13;
$001A : Result := 14;
$001B : Result := 15;
$0020 : Result := 16;
$0021 : Result := 17;
$0022 : Result := 18;
$FFFF : Result := 19;
else
Result := -1;
end;
end;
end;
Und hier zu guter letzt die Disctypes:
Delphi-Quellcode:
const
DiscTypes : Array [0..19] of String = (' No Current Profile',
' Non Removable Disk',
' Removable Disk',
' Magneto Optical Erasable',
' Optical Write Once',
' AS-MO',
' CD-ROM',
' CD-R',
' CD-RW',
' DVD-ROM',
' DVD-R SequentialRecording,',
' DVD-RAM',
' DVD-RW Restricted Overwrite',
' DVD-RW Sequential Recording',
' DVD+RW',
' DVD+R',
' DDCD-ROM',
' DDCD-R',
' DDCD-RW',
' UNKNOWN');
Hoffe du kannst was mit anfangen =)
Grüsse
Daniel
//edit hatte noch (mehr) was vergessen, jetzt ist es aber komplett, sry! jetzt aber
Daniel M.
|