diff --git a/ContextMenuManager/Controls/ShellList.cs b/ContextMenuManager/Controls/ShellList.cs index 5c53114..eb85517 100644 --- a/ContextMenuManager/Controls/ShellList.cs +++ b/ContextMenuManager/Controls/ShellList.cs @@ -131,16 +131,17 @@ namespace ContextMenuManager.Controls switch(scene) { case Scenes.File: - this.AddItem(new SpecialItems.SkypeShareItem()); + if(WindowsOsVersion.ISAfterOrEqual10) + this.AddItem(new RegRuleItem(RegRuleItem.ShareWithSkype)); break; case Scenes.Background: - this.AddItem(new RegRuleItem(RegRuleItem.CustomFolder) { MarginRight = RegRuleItem.SysMarginRignt }); + this.AddItem(new RegRuleItem(RegRuleItem.CustomFolder)); break; case Scenes.Computer: - this.AddItem(new RegRuleItem(RegRuleItem.NetworkDrive) { MarginRight = RegRuleItem.SysMarginRignt }); + this.AddItem(new RegRuleItem(RegRuleItem.NetworkDrive)); break; case Scenes.RecycleBin: - this.AddItem(new RegRuleItem(RegRuleItem.RecycleBinProperties) { MarginRight = RegRuleItem.SysMarginRignt }); + this.AddItem(new RegRuleItem(RegRuleItem.RecycleBinProperties)); break; case Scenes.Library: this.LoadItems(MENUPATH_LIBRARY_BACKGROUND); @@ -162,6 +163,7 @@ namespace ContextMenuManager.Controls private void LoadItems(string scenePath) { if(this.Scene == Scenes.CustomType && TypeItem.Extension == null) return; + RegTrustedInstaller.TakeRegKeyOwnerShip(scenePath); this.LoadShellItems(GetShellPath(scenePath)); this.LoadShellExItems(GetShellExPath(scenePath)); } diff --git a/ContextMenuManager/Controls/SpecialItems/SkypeShareItem.cs b/ContextMenuManager/Controls/SpecialItems/SkypeShareItem.cs deleted file mode 100644 index 26596aa..0000000 --- a/ContextMenuManager/Controls/SpecialItems/SkypeShareItem.cs +++ /dev/null @@ -1,112 +0,0 @@ -using BulePointLilac.Controls; -using BulePointLilac.Methods; -using ContextMenuManager.Controls.Interfaces; -using Microsoft.Win32; -using System; -using System.Drawing; -using System.IO; -using System.Windows.Forms; - -namespace ContextMenuManager.Controls.SpecialItems -{ - //所有文件的右键菜单项目:共享到Skype - //目前仅发现这一个特殊例子,不符合所有通用规则 - sealed class SkypeShareItem : MyListItem, IChkVisibleItem, ITsiFilePathItem, ITsiRegPathItem, ITsiWebSearchItem, IBtnShowMenuItem - { - const string DllPath = @"Skype\SkypeContext.dll"; - const string GuidName = "{776DBC8D-7347-478C-8D71-791E12EF49D8}"; - const string PackageRegPath = @"HKEY_CLASSES_ROOT\PackagedCom\Package"; - const string AppxRegPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx"; - - public SkypeShareItem() - { - InitializeComponents(); - string path = ItemFilePath; - if(File.Exists(path)) - { - ChkVisible.Checked = this.ItemVisible; - this.Text = ResourceString.GetDirectString($"@{path},-101"); - string exePath = $@"{Path.GetDirectoryName(path)}\Skype.exe"; - this.Image = Icon.ExtractAssociatedIcon(exePath)?.ToBitmap(); - } - else this.Visible = false; - } - - public string ItemFilePath - { - get - { - string AppxDirPath = Registry.GetValue(AppxRegPath, "PackageRoot", null)?.ToString(); - if(!Directory.Exists(AppxDirPath)) return null; - foreach(DirectoryInfo di in new DirectoryInfo(AppxDirPath).GetDirectories()) - { - if(di.Name.StartsWith("Microsoft.SkypeApp", StringComparison.OrdinalIgnoreCase)) - { - string value = $@"{di.FullName}\{DllPath}"; - if(File.Exists(value)) return value; - } - } - return null; - } - } - - private string PackageName - { - get - { - if(!File.Exists(ItemFilePath)) return null; - string[] strs = ItemFilePath.Split('\\'); - return strs[strs.Length - 3]; - } - } - - public string RegPath - { - get - { - if(PackageName == null) return null; - return $@"{PackageRegPath}\{PackageName}\Class\{GuidName}"; - } - set { } - } - - public bool ItemVisible - { - get - { - using(RegistryKey key = RegistryEx.GetRegistryKey(RegPath)) - { - if(key == null) return true; - string value = key.GetValue("DllPath")?.ToString(); - return value.Equals(DllPath, StringComparison.OrdinalIgnoreCase); - } - } - set - { - Registry.SetValue(RegPath, "DllPath", value ? DllPath : string.Empty); - } - } - - public string SearchText => Text; - - public MenuButton BtnShowMenu { get; set; } - public VisibleCheckBox ChkVisible { get; set; } - public WebSearchMenuItem TsiSearch { get; set; } - public RegLocationMenuItem TsiRegLocation { get; set; } - public FileLocationMenuItem TsiFileLocation { get; set; } - public FilePropertiesMenuItem TsiFileProperties { get; set; } - - private void InitializeComponents() - { - BtnShowMenu = new MenuButton(this); - ChkVisible = new VisibleCheckBox(this); - TsiSearch = new WebSearchMenuItem(this); - TsiFileLocation = new FileLocationMenuItem(this); - TsiFileProperties = new FilePropertiesMenuItem(this); - TsiRegLocation = new RegLocationMenuItem(this); - - ContextMenuStrip.Items.AddRange(new ToolStripItem[] { TsiSearch, - new ToolStripSeparator(), TsiFileProperties, TsiFileLocation, TsiRegLocation }); - } - } -} \ No newline at end of file diff --git a/ContextMenuManager/Properties/Resources/Images/Skype.png b/ContextMenuManager/Properties/Resources/Images/Skype.png new file mode 100644 index 0000000..84b2de0 Binary files /dev/null and b/ContextMenuManager/Properties/Resources/Images/Skype.png differ