Как зарегистрировать своё расширение?

Материал из DRKB

Как зарегистрировать своё расширение?[править | править код]

uses Registry;

procedure RegisterFileType(FileType, FileTypeName, Description, ExecCommand: string);
begin
  if (FileType = '') or (FileTypeName = '') or (ExecCommand = '') then exit;
  if FileType[1] <> '.' then
    FileType := '.' + FileType;
  if Description = '' then
    Description := FileTypeName;
  with TRegIniFile.Create do
    try
      RootKey := HKEY_CLASSES_ROOT;
      WriteString(FileType, '', FileTypeName);
      WriteString(FileTypeName, '', Description);
      WriteString(FileTypeName + '\shell\open\command', '', ExecCommand + ' "%1"');
    finally
      Free;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RegisterFileType('txt', 'TxtFile', 'Plain text', 'notepad.exe');
end;


Author: Vit (www.delphist.com, www.drkb.ru, www.unihighlighter.com, www.nevzorov.org)
Source: Взято с Vingrad.ru http://forum.vingrad.ru
ID: 01737