From 0cf869c79d7efb327387ea2767ed89b3dcaed820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Sat, 26 Dec 2020 12:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=A4=84=E7=90=86Skype?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContextMenuManager/Controls/ShellList.cs | 10 +- .../Controls/SpecialItems/SkypeShareItem.cs | 112 ------------------ .../Properties/Resources/Images/Skype.png | Bin 0 -> 1650 bytes 3 files changed, 6 insertions(+), 116 deletions(-) delete mode 100644 ContextMenuManager/Controls/SpecialItems/SkypeShareItem.cs create mode 100644 ContextMenuManager/Properties/Resources/Images/Skype.png 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 0000000000000000000000000000000000000000..84b2de0ebb73c1b0504b1122d13e78b2a5c9cd1f GIT binary patch literal 1650 zcmb`G`BT$}7R4`-R2HEuPg|p+)dT^HsHLt|D-sM(L8u@U3(~UGih{IkRa?*p7OG)U z)@p!Q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