Einzelnen Beitrag anzeigen

Muetze1
(Gast)

n/a Beiträge
 
#6

Re: Strings vergleichen geht SAULAHM!!!

  Alt 30. Dez 2004, 23:01
Moin!

Delphi-Quellcode:
function TFenster.GetImgIndex(Const AFileName: String): Byte;
Type
  TFileAsso = Record
    Ext : String;
    Idx : Integer;
  End;
Const
  coImageIndex : Array[0..38] Of TFileAsso = (
    ( Ext: 'exe'; Idx: 6 ),

    ( Ext: 'jpg'; Idx: 7 ),
    ( Ext: 'jpeg'; Idx: 7 ),
    ( Ext: 'bmp'; Idx: 7 ),
    ( Ext: 'gif'; Idx: 7 ),
    ( Ext: 'png'; Idx: 7 ),

    ( Ext: 'htm'; Idx: 8 ),
    ( Ext: 'html'; Idx: 8 ),

    ( Ext: 'txt'; Idx: 9 ),
    ( Ext: 'ini'; Idx: 9 ),
    ( Ext: 'inf'; Idx: 9 ),
    ( Ext: 'css'; Idx: 9 ),

    ( Ext: 'rar'; Idx: 10 ),
    ( Ext: 'zip'; Idx: 10 ),
    ( Ext: 'cab'; Idx: 10 ),
    ( Ext: 'ace'; Idx: 10 ),

    ( Ext: 'mp3'; Idx: 11 ),
    ( Ext: 'wav'; Idx: 11 ),
    ( Ext: 'ogg'; Idx: 11 ),
    ( Ext: 'mid'; Idx: 11 ),
    ( Ext: 'wma'; Idx: 11 ),
    ( Ext: 'rma'; Idx: 11 ),

    ( Ext: 'mpg'; Idx: 12 ),
    ( Ext: 'mpeg'; Idx: 12 ),
    ( Ext: 'mpe'; Idx: 12 ),
    ( Ext: 'wmv'; Idx: 12 ),
    ( Ext: 'avi'; Idx: 12 ),
    ( Ext: 'asf'; Idx: 12 ),
    ( Ext: 'mov'; Idx: 12 ),
    ( Ext: 'rm'; Idx: 12 ),

    ( Ext: 'doc'; Idx: 13 ),
    ( Ext: 'rtf'; Idx: 13 ),
    ( Ext: 'pdf'; Idx: 13 ),
    ( Ext: 'ppt'; Idx: 13 ),
    ( Ext: 'pps'; Idx: 13 ),

    ( Ext: 'hlp'; Idx: 14 ),
    ( Ext: 'chm'; Idx: 14 ),

    ( Ext: 'swf'; Idx: 15 ),

    ( Ext: 'lnk'; Idx: 16 ) );
var
  lExt : String;
  i : Integer;
begin
  RESULT := 17;

  lExt := Copy(LowerCase(ExtraFileExt(AFileName)), 2, MaxInt);

  If ( Length(lExt) > 0 ) Then // mehr als nur der Punkt
    For i := Low(coImageIndex) To High(coImageIndex) Do
      If ( coImageIndex[i].Ext = lExt ) Then
      Begin
        Result := coImageIndex[i].Idx;
        Break;
      End;
end;
MfG
Muetze1
  Mit Zitat antworten Zitat