uses
Registry;
procedure AddFileMenue(FilePrefix, Menue, Command: string);
var
reg: TRegistry;
typ: string;
begin
reg := TRegistry.Create;
with reg dobegin
RootKey := HKEY_CLASSES_ROOT;
OpenKey("." + FilePrefix, True);
typ := ReadString("");
if typ = "" thenbegin
typ := Fileprefix + "file";
WriteString("", typ);
end;
CloseKey;
OpenKey(typ + "\shell\" + Menue + "\command", True);
WriteString("", command + " "%1"");
CloseKey;
Free;
end;
end;
procedure DeleteFileMenue(Fileprefix, Menue: string);
var
reg: TRegistry;
typ: string;
begin
reg := TRegistry.Create;
with reg dobegin
RootKey := HKEY_CLASSES_ROOT;
OpenKey("." + Fileprefix, True);
typ := ReadString("");
CloseKey;
OpenKey(typ + "\shell", True);
DeleteKey(Menue);
CloseKey;
Free;
end;
end;
{ Example / Beispiel:}procedure TForm1.Button1Click(Sender: TObject);
begin{ Register the Menuepoint: }
AddFileMenue("rtf", "Edit with Notepad", "C:\Windows\system\notepad.exe");
{
If you now click with the right mousebutton on a *.rtf-file then
you can see a Menuepoint: "Edit with Notepad".
When Click on that point Notepad opens the file.
Wenn man nun mit der rechten Maustaste im Explorer auf eine *.rtf-Datei Clickt,
dann erscheint dort der Menuepunkt "Edit with Notepad".
Beim Clicken darauf, цffnet Notepad diese Datei.
}end;
procedure TForm1.Button2Click(Sender: TObject);
begin{
Unregister the Menuepoint / Undo your changes in the Registry:
Lцscht den Menuepunkt wieder aus der Registry:
}
DeleteFileMenue("rtf", "Edit with Notepad");
end;
Если Вас заинтересовала или понравилась информация по разработке на Delph - "Как зарегистрировать свой пункт в меню для моего типа файлов", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу: Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!