473,386 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Writing to Registry

I am trying to write to the registry and the objects that are suppose to be
handling this function are not working. Here is what is happening.

I am issuing the following commands:
RegistryKey reg =
Registry.CurrentUser.OpenSubKey("Software\\mykey\\ mysubkey\\Settings",
true);

reg.SetValue("DBPath", "c:\\temp");

when I execute these lines, the function does write to the registry,
however, it does not write to HKEY_Current_User. Its writing to HKEY_USER.
There are no entries at all in CurrentUser like the command suggests that
its writing to.

Can anyone help me with this as its been a real pain. I do this sort of
thing in Delphi everyday and have never had any problems. Can C# not work
with the registry?

Thanks,

glenn

Nov 17 '05 #1
2 1592
I have similar code, and it works just fine. I assume that you've
checked that OpenSubKey isn't returning null... that the subkey is
already in the Registry? (Well, of course, otherwise the reg.SetValue()
would have failed with a NullReferenceException, wouldn't it? :)

I have no idea why it would put the values under the wrong subkey. As I
said, my version works just fine, and I'm not doing anything different
from what you're doing, other than a CreateSubKey if OpenSubKey returns
null.

Nov 17 '05 #2

"glenn" <gh******@softeksoftware.com> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
I am trying to write to the registry and the objects that are suppose to be
handling this function are not working. Here is what is happening.

I am issuing the following commands:
RegistryKey reg =
Registry.CurrentUser.OpenSubKey("Software\\mykey\\ mysubkey\\Settings",
true);

reg.SetValue("DBPath", "c:\\temp");

when I execute these lines, the function does write to the registry,
however, it does not write to HKEY_Current_User. Its writing to
HKEY_USER. There are no entries at all in CurrentUser like the command
suggests that its writing to.

Can anyone help me with this as its been a real pain. I do this sort of
thing in Delphi everyday and have never had any problems. Can C# not work
with the registry?

Thanks,

glenn


And who's the current user? What kind of application is this (windows
service, web, console ...)?

Willy.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pat Blair | last post by:
Sorry to anyone who read this post, but in case it's useful to anyone: Further experiments reveal that while a tuple comes back if you read a multi-line string, you set the value using a list (not...
2
by: Paul P | last post by:
I am having a problem writing errors to the application log on a Windows 2003 server running IIS 6 The error message is "InvalidOperationException: Cannot open log for source {0}." I have created...
6
by: msnews.microsoft.com | last post by:
Hi all, I was trying to find an easy way to write in the standard configuration (like app.config) xml-based files. I found classes that can be used to read this information (in...
6
by: Bry | last post by:
I'm having problems writing (and reading) boolean data to the registry. // Write a boolean value to the registry // I've not included the obvious bits of code in these samples bool myBool =...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
3
by: Sreppohcdoow | last post by:
I have a simple tool that I create that stores some settings in the Registry... however, if the user running it doesn't have Admin priveleges on the machine, the app fails when trying to write to...
0
by: Chris Mullins | last post by:
I have an application that installs some 64-bit binaries for development use in Visual Studio 2005. As such I want them to appear in the .Net References menu when someone attempts to "Add...
1
by: Chris Mullins | last post by:
I need to write to the 32-bit registry, and need to do so from a 64-bit MSI. It never occurred to me that this would be difficult... I have an application that installs some 64-bit binaries for...
1
by: projectVBA | last post by:
Hi , I wrote some add in for PowerPoint and i'm trying to find an automatic way to load it every time PowerPoint starts. I found Microsoft Code example (see below ) BUT the problem is : I can't...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.