Skip to content

Commit

Permalink
fix x86 apps
Browse files Browse the repository at this point in the history
  • Loading branch information
1357310795 committed Jul 9, 2022
1 parent 3ac3c53 commit ab8c259
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
29 changes: 23 additions & 6 deletions MyComputerManager/Helpers/NamespaceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,27 @@ public static List<NamespaceItem> GetItemsInternal(RegistryKey rootkey, bool dis
return new List<NamespaceItem>();
foreach (var item in LocalMachineNamespace.GetSubKeyNames())
{
var clsidkey = Registry.ClassesRoot.OpenSubKey(@"CLSID", false);
var clsidrootkey = Registry.CurrentUser;
var clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false);
var itemkey = clsidkey.OpenSubKey(item, false);
//var clsidkey = rootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false);
//var itemkey = clsidkey.OpenSubKey(item, false);
if (itemkey == null)
{
clsidrootkey = Registry.LocalMachine;
clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false);
itemkey = clsidkey.OpenSubKey(item, false);
}
if (itemkey == null)
{
clsidrootkey = Registry.CurrentUser;
clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\WOW6432Node\CLSID", false);
itemkey = clsidkey.OpenSubKey(item, false);
}
if (itemkey == null)
{
clsidrootkey = Registry.LocalMachine;
clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\WOW6432Node\CLSID", false);
itemkey = clsidkey.OpenSubKey(item, false);
}
if (itemkey != null)
{
var iconkey = itemkey.OpenSubKey("DefaultIcon");
Expand All @@ -72,7 +89,7 @@ public static List<NamespaceItem> GetItemsInternal(RegistryKey rootkey, bool dis
string exepath = (string)(exekey?.GetValue("") ?? "");

if (name == "") continue;
list.Add(new NamespaceItem(name, desc, tip, exepath, iconpath, rootkey, disabled, item));
list.Add(new NamespaceItem(name, desc, tip, exepath, iconpath, rootkey, clsidkey, disabled, item));
}
}
return list;
Expand All @@ -88,7 +105,7 @@ public static CommonResult UpdateItem(NamespaceItem item)
var namespaceSubKey = namespaceKey.CreateSubKey(item.CLSID, true);
if (namespaceSubKey == null)
return new CommonResult(false, "找不到Namespace下的" + item.CLSID);
var clsidKey = Registry.ClassesRoot.CreateSubKey(@"CLSID", true);
var clsidKey = item.RegKey1;
if (clsidKey == null)
return new CommonResult(false, "找不到CLSID key");
var clsidSubKey = clsidKey.CreateSubKey(item.CLSID, true);
Expand Down Expand Up @@ -179,7 +196,7 @@ public static CommonResult DeleteItem(NamespaceItem item)
return new CommonResult(false, "找不到Namespace key");
namespaceKey.DeleteSubKeyTree(item.CLSID, false);

var clsidKey = item.RegKey.OpenSubKey(@"SOFTWARE\Classes\CLSID", true);
var clsidKey = item.RegKey1;
if (clsidKey == null)
return new CommonResult(false, "找不到CLSID key");
clsidKey.DeleteSubKeyTree(item.CLSID, false);
Expand Down
8 changes: 6 additions & 2 deletions MyComputerManager/Models/NamespaceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ public NamespaceItem()
{

}
public NamespaceItem(string name, string desc, string tip, string exePath, string iconPath, RegistryKey key, bool disabled, string cLSID)
public NamespaceItem(string name, string desc, string tip, string exePath, string iconPath, RegistryKey key, RegistryKey key1, bool disabled, string cLSID)
{
Name = name;
Desc = desc;
Tip = tip;
ExePath = exePath;
IconPath = iconPath;
RegKey = key;
RegKey1 = key1;
isEnabled = !disabled;
CLSID = cLSID;
}
Expand All @@ -33,6 +34,7 @@ public NamespaceItem(string name)
{
Name = name;
RegKey = Registry.CurrentUser;
RegKey1 = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Classes\CLSID", true);
isEnabled = true;
CLSID = null;
Desc = "";
Expand Down Expand Up @@ -133,6 +135,7 @@ public bool IsEnabled
}

public RegistryKey RegKey { get; set; }
public RegistryKey RegKey1 { get; set; }

public string RegKey_Namespace
{
Expand All @@ -145,7 +148,7 @@ public string RegKey_CLSID
{
get
{
return @"HKEY_CLASSES_ROOT\CLSID\" + CLSID;
return RegKey1.Name + @"\" + CLSID;
}
}

Expand All @@ -159,6 +162,7 @@ public NamespaceItem Clone()
Tip = Tip,
IconPath = IconPath,
RegKey = RegKey,
RegKey1 = RegKey1,
IsEnabled = IsEnabled,
Icon = Icon,
ExePath = ExePath
Expand Down

0 comments on commit ab8c259

Please sign in to comment.