Mega Code Archive

 
Categories / Delphi / Files
 

Gerçekten zipmi

//www.dronymc.cjb.net //drony@mynet.com //icq:266148308 {ilk 4 byte'a bakarak karşılaştırma yapıyo bu yöntem kesinlikle %100 doğru değildir çünkü başka bir programında ilk 4 byte'ı aynı olabilir bu yöntemi diğer dosyalar içinde uygulayabilirsiniz } Function IsZipFile ( const fname : string ) : Boolean; Var oldmode : byte; f : file; buf : array [0..3] of char; Begin Result := False; if fname = '' then exit; oldmode := filemode; filemode := fmOpenRead or fmShareDenyWrite; Assign ( f, fname ); {$i-} Reset ( f, 1 ); {$i+} filemode := oldmode; If ioresult <> 0 then exit; {$i-} BlockRead ( f, buf, 4 ); {$i+} if ioresult = 0 then Result := ( buf [0] = 'P' ) and ( buf [1] = 'K' ) and ( buf [2] = #3 ) and ( buf [3] = #4 ); Close ( f ); End;