Tag: 注册表

SetValue 64位机器注册表

我想在下面的注册表路径中为’NoModify’设置一个值。 “HKEY_LOCAL_MACHINE \ SOFTWARE \微软\的Windows \ CurrentVersion \卸载\ XXXX” 我使用下面的代码,它只适用于X86机器。 你能看出为什么这对x64机器不起作用的原因吗? // This value is correct RegistryView registryView = releaseFlags.Contains(“PLATFORM_X86″) ? RegistryView.Registry64 : RegistryView.Registry32; using (RegistryKey hkeyLocalMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView)) { RegistryKey noModifyKey = hkeyLocalMachine.OpenSubKey(@”SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{xxxx}”, true); //SL: Key Name if (noModifyKey != null) { noModifyKey.SetValue(“NoModify”, 0); noModifyKey.Flush(); } }

webbrowser使用ie10 c#winform

我想强制webbrowser在我的c#winform应用程序中使用IE10。 我知道还有其他这样的问题,但我已经阅读了很多这些问题,我不知道我哪里错了。 这是我的代码: RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey (@”SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION”, true); registrybrowser.SetValue(“myAppName”, 0x02710, RegistryValueKind.DWord); //Even with QWord 我尝试过不同的方法来设置值: registrybrowser.SetValue(“myAppName”, 1000, RegistryValueKind.DWord); //Even with QWord and String registrybrowser.SetValue(“myAppName”, 1000); //even with 0x02710 我在InitializeComponent()之前在主项目的costructor中编写它。 我在.manifest文件中设置了管理员权限 感谢所有人,BlackShawarna 编辑:我发现了RegistryKey.SetValue(…); 在另一条路径中创建了一个键: (@”SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION”) 即使我的指令说: Registry.LocalMachine.OpenSubKey (@”SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION”, true); 我认为这是因为IE10适用于32位模式。 但是我不明白为什么它写在那条路径中,即使我指定了另一条路径,最重要的是,即使我打开Registry.LocalMachine.OpenSubKey(@“Software \ Wow6432Node ….”),为什么我的应用程序无法工作。 ); 如果我只在x64模式下运行我的程序,转到properties / build / x64,它将不会在我的原始路径中写入密钥。

Registry.GetValue有什么问题?

我试图获得一个注册表值: var value = Registry.GetValue(@”HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography”, “MachineGuid”, 0); 在Windows XP中一切正常,但在Windows 7中返回0.在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography使用regedit我看到MachineGuid ,但如果我运行 var keys = Registry.LocalMachine.OpenSubKey(“SOFTWARE”).OpenSubKey(“Microsoft”).OpenSubKey(“Cryptography”, RegistryKeyPermissionCheck.ReadSubTree).GetValueNames(); keys.Length为0。 我做错了什么? 其他值都可以在OS中完成。

C#读取注册表:ProductID在x86目标应用程序中返回null。 “任何CPU”工作正常

我最近搬到了VS 2010的W7 64位机器上。我的项目设置为在Any CPU上运行。 当我将其更改为针对x86我注意到我的一些注册表调用不再有效。 我试图像这样读取ProductID字段: RegistryKey windowsNTKey = Registry.LocalMachine.OpenSubKey(@”Software\Microsoft\Windows NT\CurrentVersion”); object productID = windowsNTKey.GetValue(“ProductId”); 在x86模式下运行时, productID始终为null ,当在“任何CPU”中运行时,它正常工作。 这里发生了什么?

DeleteSubKey UnauthorizedAccessException

我正在尝试编写一个快速应用程序来修改一些注册表项。 当我通过RegEdit浏览时,我可以毫无问题地修改和删除密钥。 但是当我尝试使用RegistryKey.DeleteSubKey()它会抛出一个UnauthorizedAccessException 。 有没有办法获得这样做的特权? 另外,如果我的用户帐户显然有权进行更改,为什么会出现问题呢? 编辑: 这是一些代码 RegistryKey reg; try { reg = Registry.CurrentUser.OpenSubKey(BaseKey); reg.DeleteSubKey(“{” + Item.Guid.ToString() + “}”); } catch { return false; }

C#Windows服务需要进行注册表更改

我有一项服务需要每5分钟更新一次注册表(抵消gpo)。 代码在常规应用程序中运行良好,但是当我将它放在Windows服务中时,它不会进行更改。 我使用本地系统帐户进行​​服务,并没有抛出任何exception 以下代码适用于常规控制台应用,但不适用于服务: RegistryKey key = Registry.CurrentUser.OpenSubKey(“Control Panel\\Desktop”, true); if (key != null) { key.SetValue(“ScreenSaverIsSecure”, “0”, RegistryValueKind.String); key.SetValue(“ScreenSaveActive”, “0”, RegistryValueKind.String); key.SetValue(“ScreenSaveTimeOut”, “0”, RegistryValueKind.String); key.SetValue(“SCRNSAVE.EXE”, “”, RegistryValueKind.String); } key = Registry.CurrentUser.OpenSubKey(@”Software\Policies\Microsoft\Windows\Control Panel\Desktop”, true); if (key != null) { key.SetValue(“ScreenSaverIsSecure”, “0”, RegistryValueKind.String); key.SetValue(“ScreenSaveActive”, “0”, RegistryValueKind.String); key.SetValue(“ScreenSaveTimeOut”, “0”, RegistryValueKind.String); key.SetValue(“SCRNSAVE.EXE”, “”, RegistryValueKind.String); } System.Diagnostics.Process.Start(@”c:\windows\System32\RUNDLL32.EXE”, “user32.dll, UpdatePerUserSystemParameters”); 有任何想法吗? […]

如何检查C#中是否安装了特定版本的Flash播放器。?

我想从我的代码中查看是否安装了特定版本的Flash播放器。 我使用了以下代码 using Microsoft.Win32 RegistryKey RK = Registry.CurrentUser.OpenSubKey(“HKEY_LOCAL_MACHINE\\SOFTWARE\\Macromedia\\FlashPlayer”); if (RK != null) { // It’s there } else { // It’s not there } 在注册表中如果我搜索版本10.2.161.23的Flash播放器,位置 “HKEY_LOCAL_MACHINE \ SOFTWARE \ Macromedia的” 有2个文件夹: FlashPlayer和 FlashPlayerActiveX。 但是,我上面的代码不起作用。 请告诉我如何检查系统中是否安装了特定版本的Flash播放器,以及是否使用C#.NET 。

为什么迭代枚举返回重复键?

我现在正在处理有关注册表的一些事情。 我检查了System.Security.AccessControl的枚举RegistryRights 。 public enum RegistryRights { QueryValues = 1, SetValue = 2, CreateSubKey = 4, EnumerateSubKeys = 8, Notify = 16, CreateLink = 32, Delete = 65536, ReadPermissions = 131072, WriteKey = 131078, ExecuteKey = 131097, ReadKey = 131097, ChangePermissions = 262144, TakeOwnership = 524288, FullControl = 983103, } 这个枚举是一个按位,我知道枚举可以包含重复的值。 我试图通过这段代码迭代枚举: foreach (System.Security.AccessControl.RegistryRights regItem […]

寻找C#注册表类

寻找包含调用的C#类来执行以下操作: 读写密钥值读写密钥条目 枚举键中的条目。 这个很重要。 例如,需要列出以下所有条目:HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBC.INI \ ODBC数据源 (我扫描了一些codeproject.com注册表类,他们没有枚举)

获取已安装产品列表c#

要安装/卸载/更新我们的软件,我们的自定义安装程序使用WindowsInstaller.Installer.Products从Windows注册表中获取已安装产品的列表。 在某些客户端计算机上,未知软件可能会在注册表“ HKEY_LOCAL_MACHINE \ SOFTWARE \ Classes \ Installer \ Products ”中添加一个新条目,其名称类似于“ABCD”。 这导致WindowsInstaller.Installer.Products抛出exception。 我可以通过手动将注册表项条目添加到名为“test”的“ HKEY_LOCAL_MACHINE \ SOFTWARE \ Classes \ Installer \ Products ”中来创建此方案。 如果我将测试重命名为新的GUID,那么模拟的问题就会得到解决。 你能建议任何可能的解决方法/解决方案吗? 使用MSIINV.exe工具会很困难,因为这是第三方工具,但这似乎有所帮助。