type TIEContextMenuFactory = class(TAutoObjectFactory) public procedure UpdateRegistry(Register: Boolean); override; end;
procedure AddExtMenuItem(MenuText, Url: string; Contexts:DWord); var reg: TRegistry; begin Reg := TRegistry.Create; with Reg do try RootKey := HKEY_CURRENT_USER; OpenKey('\Software\Microsoft\Internet Explorer\MenuExt\' + MenuText, True); WriteString('', Url); WriteInteger('contexts', contexts); CloseKey; finally Free; end; end;
procedure RemoveExtMenuItem(MenuText: string); var reg: TRegistry; begin Reg := TRegistry.Create; with Reg do try RootKey := HKEY_CURRENT_USER; DeleteKey('\Software\Microsoft\Internet Explorer\MenuExt\' + MenuText); finally Free; end; end;
… procedure TIEContextMenuFactory.UpdateRegistry(Register: Boolean); begin inherited; if Register then AddExtMenuItem('¸′复制链接文本', ExtractFilePath(GetDllName)+'copyurl.htm',32) else RemoveExtMenuItem('¸′复制链接文本'); end;