Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 2nd, 2005, 2:33 AM   #1
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Exception writing to registry... why?

I am using a bit of code in C# to write a simple string value to the registry with very very little luck, it keeps trowing an exception every single time saying I do not have write access to the registery, or it can not write to the registry (I forget extactly)... this is the offending code:

RegistryKey registryKey = Registry.CurrentUser;
registryKey - registryKey.OpenSubKey( @"Software\CrDev Consulting\WinVOBGlue\" );
registryKey.SetValue(  "tempdir", this.temporaryDirectory.Text );
registryKey.Close( )

the tempdir value already exists within the registry, basically all I am doing is overwriting it, I tried deleting it first but as soon as Delete is called it says that it can not write the registry... is there something I am doing wrong here?

Any ideas as to what could be causing this error? I am running the application as an administrator, and it can read the value without any problems... but since it is HKCU there should be no problems, even if I am not the administrator when writing to this key.

Any help would be greatly appreciated.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jun 2nd, 2005, 3:06 AM   #2
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Oh yeah, I feel dumb for this one.... the problem is actually with OpenSubKey( "..." ); This function is overloaded and that is the ReadOnly form of the function... OpenSubKey( "...", true ); is how the function is called to open the key with write permissions.. took me an entire day to figure this one out, lol.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jun 2nd, 2005, 12:03 PM   #3
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
Just need to make sure what you have is exactly like the examples. They almost always work. :p
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote
Old Jun 4th, 2005, 10:14 PM   #4
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Actually I failed to realize that the problem was with that function to begin with. i thought it was a permission problem or a problem with the set value function. It was not until I did a bit of searching though google that I saw an example that used a second value for the OpenSubKey function, and then it all made sense.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:07 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC