Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: WinAPI и системное программирование > Как зарегистрировать своё расширение?


Автор: Alex 5.11.2004, 20:31
Код

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;

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)