Entwickler-Ecke

Multimedia / Grafik - Audio-CD?


GSE - Sa 10.05.03 11:38
Titel: Audio-CD?
Hi Leutz,

Wie kann ich herausfinden ob eine CD eine Audio-CD ist und wieviele Titel sie hat? Danke schon im Vorraus.

mfg
GSE


Ex0rzist - Sa 10.05.03 15:25

Hallo,

das sollte dir weiterhelfen. Bei funktioniert es wunderbar.

Zu Erstens:
http://www.swissdelphicenter.ch hat folgendes geschrieben:

Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
function IsAudioCD(Drive: Char): Boolean; 
var 
  DrivePath: string; 
  MaximumComponentLength: DWORD; 
  FileSystemFlags: DWORD; 
  VolumeName: string; 
  OldErrorMode: UINT; 
  DriveType: UINT; 
begin 
  Result := False; 
  DrivePath := Drive + ':\'; 
  OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); 
  try 
    DriveType := GetDriveType(PChar(DrivePath)); 
  finally 
    SetErrorMode(OldErrorMode); 
  end; 
  if DriveType <> DRIVE_CDROM then 
    Exit; 
  SetLength(VolumeName, 64); 
  GetVolumeInformation(PChar(DrivePath), 
    PChar(VolumeName), 
    Length(VolumeName), 
    nil, 
    MaximumComponentLength, 
    FileSystemFlags, 
    nil, 
    0); 
  if lStrCmp(PChar(VolumeName), 'Audio-CD') = 0 then Result := True; 
end; 


procedure TForm1.Button1Click(Sender: TObject); 
begin 
  if IsAudioCD('D') then 
    ShowMessage('Audio-CD found in drive D.') 
  else 
    ShowMessage('No Audio-CD found in drive D.'); 
end;


Zu Zweitens:

Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Function GetTracks(CDROM:string):String;  //GetTracks erwartet 
                                          //als Parameter den Pfad zum CD-ROM
var
 Anzahl:array[0..29]of char;
Begin
 mciSendString(pchar('open '+CDROM+' type cdaudio alias Laufwerk'),nil,0,0);
 mciSendString(pchar('status Laufwerk number of tracks wait'), Anzahl, 30, 0);
 mciSendString('close Laufwerk',nil,0,0);
 Result := Anzahl;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Showmessage('Es sind '+GetTracks('F:\')+' auf der CD.');
end;


GSE - So 11.05.03 18:48

Vielen Dank, Ex0rzist! :D

Genau das was ich gesucht habe!

mfg
GSE