C#无法删除Win 7 64位PC中的注册表项 [英] C# Unable to delete registry key in Win 7 64 Bit PC

查看:116
本文介绍了C#无法删除Win 7 64位PC中的注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我无法从Win 7 64位删除特定的注册表项。删除命令结果是成功的,但是当我去检查注册表时,该条目存在。

在Win7 32位和其他操作系统中,它成功运行精细删除。问题在于64位操作系统。

下面是代码片段:



Hello All,

I am unable to delete a particular registry key from Win 7 64 bit. The deletion command result is successful but when i go and check in registry, the entry exists.
In Win7 32 bit and other OS, it runs fine-deletes successfully. The problem is in 64 bit OS.
Below is the code snippet:

RegistryKey registrykeyHKLM = Registry.LocalMachine;
          string keyPath = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield_{3BFAF362-6DB8-46EA-98BB-713388534EB1}";

          RegistryKey rk2 = Registry.LocalMachine.CreateSubKey(keyPath);

          if (rk2 != null)
          {
              errlog.WriteLogMsg("Found the registry: " + keyPath);
              // Deleting uninstall registry key entries
              registrykeyHKLM.DeleteSubKey(keyPath);
          }

          rk2.Close();
          registrykeyHKLM.Close();

          //Checking for successful deletion of Uninstall registry keys
          try
          {
              RegistryKey rk = Registry.LocalMachine.OpenSubKey(keyPath,true);

              if (rk != null)
              {
                  errlog.WriteLogMsg("Registry found. Unable to delete registry key: " + keyPath);
                  errlog.WriteLogMsg("Failed to delete Uninstall Information Registry Entries!!!");
                  //MessageBox.Show("Failed to delete Uninstall Information Registry Entries!!!");//2.0.0 (DKD)
              }
              else
              {
                  errlog.WriteLogMsg("Successfully deleted registry key: " + keyPath);
              }
          }
          catch (Exception ex1)
          {
              errlog.WriteLogMsg("Exception while deleting registry entries");
              errlog.WriteErrorLog(ex1);
          }





注意:我尝试访问的注册表项不在Wow6432节点中..它在64和64的共同位置32位机器。但我仍然无法在64位机器中删除该特定键。我尝试访问的keyPath对于64位和32位都是常见的,我可以读取,修改值但是我无法删除密钥



请帮忙

谢谢&问候

Dinesh



NOTE: The registry entry which i am trying to access is not in Wow6432 node.. its in a common place in both 64 & 32 bit machines. But still i am not able to delete that particular key in 64 bit machine. The keyPath which iam trying to access is common for both 64 bit and 32 bit,i can read,modify the value but iam not able to Delete the key

Please help
Thanks & regards
Dinesh

推荐答案

尝试使用此版本的删除 [ ^ ],并捕获引发的任何异常。
Try it with this version of the delete[^], and catch any exceptions that are raised.


这篇关于C#无法删除Win 7 64位PC中的注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆