wpe3B.gif (983 bytes) jsRegFileTypes

Given a file name, this very handy non-visual component reads the windows registry for the file type, file open cmd (ie. the application associated with the file), or executes the associated application.

Example:

  // gets file type from windows registry for 'txt'
sType := jsRegFileTypes.GetFileTypeFromExt('txt');  
ShowMessage(sType);   // message displayed is 'Text document'
  // runs notepad.exe and loads info.txt within it
jsRegFileTypes.ExecCommandShellForFile('info.txt');

type TjsRegFileTypes = class(TComponent)
private
    FItems : TStringList;
    FRegistry : TRegistry;
    procedure CopyRegistryFileTypesToItems;
protected
    { Protected declarations }
public
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
    function GetFileTypeFromExt(sExt : String) : String;
    function GetShellOpenCmdFromExt(sExt : String) : String;
    function ExecCommandShellForFile(sFileName : String) : Boolean;
published
    { Published declarations }
    property Items : TStringList read FItems;
end;