Registry Manipulation - Odd behaviour
-
Hi Guys, I've got a little wrapper class that exposes some registry properties in my code. This works and passes the unit test for writing and reading the value and comparing the result. However, when i look in the registry, there's no section for the values i am manipulating.
public static void SetGroupRegInfo(string group, string key, string value) { RegistryKey rkApp = Registry.LocalMachine.CreateSubKey( REGISTRY\_MICA\_GROUPS + "\\\\" + group, RegistryKeyPermissionCheck.ReadWriteSubTree); try { rkApp.SetValue(key, value); } finally { rkApp.Close(); } } public static string GetGroupRegInfo(string group, string key) { RegistryKey rkApp = Registry.LocalMachine.OpenSubKey( REGISTRY\_MICA\_GROUPS + "\\\\" + group, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.QueryValues); if (rkApp == null) return null; try { return (string)rkApp.GetValue(key); } finally { rkApp.Close(); } }
The base registry entries are created correctly by the application installer, but these values just don't seem to appear. Any thoughts? Regards Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.
-
Hi Guys, I've got a little wrapper class that exposes some registry properties in my code. This works and passes the unit test for writing and reading the value and comparing the result. However, when i look in the registry, there's no section for the values i am manipulating.
public static void SetGroupRegInfo(string group, string key, string value) { RegistryKey rkApp = Registry.LocalMachine.CreateSubKey( REGISTRY\_MICA\_GROUPS + "\\\\" + group, RegistryKeyPermissionCheck.ReadWriteSubTree); try { rkApp.SetValue(key, value); } finally { rkApp.Close(); } } public static string GetGroupRegInfo(string group, string key) { RegistryKey rkApp = Registry.LocalMachine.OpenSubKey( REGISTRY\_MICA\_GROUPS + "\\\\" + group, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.QueryValues); if (rkApp == null) return null; try { return (string)rkApp.GetValue(key); } finally { rkApp.Close(); } }
The base registry entries are created correctly by the application installer, but these values just don't seem to appear. Any thoughts? Regards Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.
I find your post confusing. You say the Unit Tests pass but we have no idea what is being tested. You say "it works" but the value is not in the registry so I have no idea what "it works" means because to me if the value is not written to the registry then I would say it is NOT working.
-
Hi Guys, I've got a little wrapper class that exposes some registry properties in my code. This works and passes the unit test for writing and reading the value and comparing the result. However, when i look in the registry, there's no section for the values i am manipulating.
public static void SetGroupRegInfo(string group, string key, string value) { RegistryKey rkApp = Registry.LocalMachine.CreateSubKey( REGISTRY\_MICA\_GROUPS + "\\\\" + group, RegistryKeyPermissionCheck.ReadWriteSubTree); try { rkApp.SetValue(key, value); } finally { rkApp.Close(); } } public static string GetGroupRegInfo(string group, string key) { RegistryKey rkApp = Registry.LocalMachine.OpenSubKey( REGISTRY\_MICA\_GROUPS + "\\\\" + group, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.QueryValues); if (rkApp == null) return null; try { return (string)rkApp.GetValue(key); } finally { rkApp.Close(); } }
The base registry entries are created correctly by the application installer, but these values just don't seem to appear. Any thoughts? Regards Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.
Hi, I would guess you're running on Vista or higher, which virtualizes all registry hives but current_user when running below elevated admin level, whereas your installer (and your unit tests?) probably runs as elevated admin and creates and uses the proper keys. A regular user is not supposed to modify local_machine keys, since they extend beyond his realm. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
I find your post confusing. You say the Unit Tests pass but we have no idea what is being tested. You say "it works" but the value is not in the registry so I have no idea what "it works" means because to me if the value is not written to the registry then I would say it is NOT working.
can't stay away for more than 8 minutes, can you? :laugh:
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
can't stay away for more than 8 minutes, can you? :laugh:
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Exactly, that[^] and your above message are 8 minutes apart. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Exactly, that[^] and your above message are 8 minutes apart. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Luc Pattyn wrote:
and your above message are 8 minutes apart.
That time is the original post, I modified it twice, see where I say "I just changed my mind". ;)
I see. I never mind the "modified at..." message that gets added automatically, it uses Bujumbura local time or something similar, doesn't tell me much. In the mean time, you're still here. Which is great. BTW: if and when the new be-really-kind rules would really cripple you, you can always put a leaded answer in one of the soapboxes/back rooms, and just reply with a link to it. :-D
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
I find your post confusing. You say the Unit Tests pass but we have no idea what is being tested. You say "it works" but the value is not in the registry so I have no idea what "it works" means because to me if the value is not written to the registry then I would say it is NOT working.
Well, "it works" would mean that the unit test does the following: * Write a value to the registry via the wrapper * Read a value from the registry via the wrapper * Assert that the value read is equal to the value written So the fact that these values don't appear in the registry confuses me too and I'm inclined to agree that it appears to be not working, hence i posted here. :P
------------------------------- Carrier Bags - 21st Century Tumbleweed.
-
Hi, I would guess you're running on Vista or higher, which virtualizes all registry hives but current_user when running below elevated admin level, whereas your installer (and your unit tests?) probably runs as elevated admin and creates and uses the proper keys. A regular user is not supposed to modify local_machine keys, since they extend beyond his realm. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
Yes, I'm on vista. What effect will this have if i shutdown and re-start? Does the registry for my local machine get burned? Is there any way around this without admin rights?
------------------------------- Carrier Bags - 21st Century Tumbleweed.
-
Yes, I'm on vista. What effect will this have if i shutdown and re-start? Does the registry for my local machine get burned? Is there any way around this without admin rights?
------------------------------- Carrier Bags - 21st Century Tumbleweed.
Tristan Rhodes wrote:
without admin rights?
use current_user. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.