Einzelnen Beitrag anzeigen

NicoDE
(Gast)

n/a Beiträge
 
#14

Re: Nur CD/DVD ROM Laufwerke auslesen..

  Alt 11. Mär 2004, 18:04
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  BufferLength: DWORD;
  DriveStrings: LPTSTR;
  CurrentDrive: LPTSTR;
  ReturnValue: DWORD;
begin
  BufferLength := GetLogicalDriveStrings(0, nil);
  if (BufferLength > 0) then
  begin
    DriveStrings := LPTSTR(GetMemory(
      (BufferLength + 1) * SizeOf(DriveStrings[0])));
    if (DriveStrings <> nil) then
    try
      ReturnValue := GetLogicalDriveStrings(BufferLength, DriveStrings);
      if (ReturnValue > 0) and (ReturnValue <= BufferLength) then
      begin
        CurrentDrive := DriveStrings;
        while (CurrentDrive[0] <> #0) do
        begin
          if (GetDriveType(CurrentDrive) = DRIVE_CDROM) then
            MessageBox(Handle, CurrentDrive, 'CD-ROM', MB_OK);

          CurrentDrive := LPTSTR(@CurrentDrive[StrLen(CurrentDrive) + 1]);
        end;
      end;
    finally
      FreeMemory(DriveStrings);
    end;
  end;
end;
  Mit Zitat antworten Zitat