...get the windows file type?

Author: Michael R. Schäfer 

0 Comments to this tip [Write new comment]

[ Print tip ]    

 

Tip Rating (5):  

Skill:  

Useful:  

Overall:  

 

 

 

uses

  ShellAPI;

 

function MrsGetFileType(const strFilename: string): string;

var

  FileInfo: TSHFileInfo;

begin

  FillChar(FileInfo, SizeOf(FileInfo), #0);

  SHGetFileInfo(PChar(strFilename), 0, FileInfo, SizeOf(FileInfo), SHGFI_TYPENAME);

  Result := FileInfo.szTypeName;

end;

 

 

// Beispiel:

// Example:

procedure TForm1.Button1Click(Sender: TObject);

begin

  ShowMessage('File type is: ' + MrsGetFileType('c:\autoexec.bat'));

end;