Tag: registry

在C#中获取已安装程序的exe名称?

我用它来获取程序名称,但我需要exe名称。 我怎么找到它们? string SoftwareKey = “SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products”; RegistryKey rk = default(RegistryKey); rk = Registry.LocalMachine.OpenSubKey(SoftwareKey); //string skname = null; string sname = string.Empty; foreach (string skname in rk.GetSubKeyNames()) { try { sname = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skname).OpenSubKey(“InstallProperties”).GetValue(“DisplayName”).ToString(); listBox1.Items.Add(sname); } catch (Exception ex) { MessageBox.Show(ex.Message); } } 我想这样做: System.Diagnostics.Process.Start(“Name.exe”); 运行程序。

为什么注册表写在不同于预期的位置?

我尝试将注册表子项及其对应的值写入注册表,如下所示: const string subKey = @”SOFTWARE\Apple\Banana\”; const string regKey = “pip”; var rk = Registry.LocalMachine.OpenSubKey(subKey); if (rk == null) rk = Registry.LocalMachine.CreateSubKey(subKey); var rv = rk.GetValue(regKey); if (rv == null) rk.SetValue(regKey, “XXX”); return rv.ToString(); 现在的问题是,当我手动查看位置(通过注册表)时,我无法在HKLM看到文件夹SOFTWARE\Apple\Banana 。 但是当我再次运行上面的代码并进行调试时,我可以看到Registry.LocalMachine.OpenSubKey(subKey)和rk.GetValue(regKey)产生之前保存的值。 然而,我没有通过regedit看到给定位置的值。 所以在搜索注册表时,我可以在以下位置看到上面的键和值: HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Apple\Banana HKEY_USERS\S-1-5-21-44266131-1313801407-2392705078-1000\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Apple\Banana 在两者之下,价值保持与我保存完全一样。 所以我意识到这是我的应用程序读取值的地方虽然在我的代码中我从HKLM\SOFTWARE\Apple\Banana\调用它。 为什么会这样? 它与访问权限问题有关吗? 这是预期的行为吗? 从某种意义上说,这个值对我来说非常重要,所以我只知道是否存在与自动重定位相关的风险! 是否有正确的方式写入注册表,以便它保持在其确切的位置.. 我的帐户是管理员一,我使用的是32位Windows 7。 编辑:据我所知,注册表项存储在当前用户位置而不是HKLM中。 当我从另一个帐户查询reg值时,我没有得到该值。 简而言之,首先将它保存到HKLM没有意义:(

访问HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Installer \ UserData

任何人都可以告诉我为什么我无法访问”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData”的注册表项? 如果我查询”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer”的GetSubKeysNames ,它只返回一个值为”Secure”值—->所有其他子键在哪里? 谢谢。

阅读注册表项

我有一个Web应用程序,它从bin文件夹导入DLL。 const string dllpath = “Utility.dll”; [DllImport(dllpath)] 现在我想要做的是首先从不在当前项目中但在某个不同位置的文件夹中导入DLL。 该文件夹的路径存储在注册表项中。 我该怎么做? 编辑 : 为什么我不能解决这个问题? public partial class Reports1 : System.Web.UI.Page { RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@”Software\xyz”); string pathName = (string)registryKey.GetValue(“BinDir”); const string dllpath = pathName; [DllImport(dllpath)] public static extern bool GetErrorString(uint lookupCode, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder buf, uint bufSize); protected void Page_Load(object sender, EventArgs e) { string pathName = […]

访问Visual Studio 2017的私有注册表配置单元

Visual Studio使用私有注册表配置单元而不是“污染”系统注册表 – 通常在这样的地方找到: C:\Users\Abx\AppData\Local\Microsoft\VisualStudio\15.0_4b0ba1c0\privateregistry.bin [为了确定已安装的扩展,我们需要查看以下密钥: Software\Microsoft\VisualStudio\15.0_4b0ba1c0\ExtensionManager\EnabledExtensions ] 在C#中通过键加载和访问此文件的最简单方法是什么?