473,327 Members | 2,090 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,327 software developers and data experts.

OpenSubKey() return a null value when existing the right key.

Leo
Hey, guys
Please see the code below:
/////************************************************
RegistryKey rkHive = null;
RegistryKey rk = null;
string target = "127.0.0.1";
rkHive = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMa chine,
this.target);
try
{
rk = rkHive.OpenSubKey(oro.key.Value);
//rkHive = {HKEY_LOCAL_MACHINE}
//oro.key.Value="\\SOFTWARE\\Classes\\.wax"
//And its data type is string.
}
//after the operation
//rk = null;
//It is abnormal as there is the right key in the right position
catch (System.Exception e)
{
Log(e);
}
//////************************************************** ***
We have some subkey below "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.wax"
But after the operation the rk still equal to null and there isn't any
exception.

Has someone met the same situation?

Nov 16 '06 #1
2 2057
Hi Leo,

When you open a SubKey, you must not have the preseding //. In your case
oro.key.Value should be SOFTWARE\\Classes\\.wax, not
\\SOFTWARE\\Classes\\.wax.

Cheers,
Chester

"Leo" wrote:
Hey, guys
Please see the code below:
/////************************************************
RegistryKey rkHive = null;
RegistryKey rk = null;
string target = "127.0.0.1";
rkHive = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMa chine,
this.target);
try
{
rk = rkHive.OpenSubKey(oro.key.Value);
//rkHive = {HKEY_LOCAL_MACHINE}
//oro.key.Value="\\SOFTWARE\\Classes\\.wax"
//And its data type is string.
}
//after the operation
//rk = null;
//It is abnormal as there is the right key in the right position
catch (System.Exception e)
{
Log(e);
}
//////************************************************** ***
We have some subkey below "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.wax"
But after the operation the rk still equal to null and there isn't any
exception.

Has someone met the same situation?

Nov 16 '06 #2
Leo
It is really make sence.
thanks, Chester.
It is so kind of you.

Cheers,
Leo

"Chester дµÀ£º
"
Hi Leo,

When you open a SubKey, you must not have the preseding //. In your case
oro.key.Value should be SOFTWARE\\Classes\\.wax, not
\\SOFTWARE\\Classes\\.wax.

Cheers,
Chester

"Leo" wrote:
Hey, guys
Please see the code below:
/////************************************************
RegistryKey rkHive = null;
RegistryKey rk = null;
string target = "127.0.0.1";
rkHive = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMa chine,
this.target);
try
{
rk = rkHive.OpenSubKey(oro.key.Value);
//rkHive = {HKEY_LOCAL_MACHINE}
//oro.key.Value="\\SOFTWARE\\Classes\\.wax"
//And its data type is string.
}
//after the operation
//rk = null;
//It is abnormal as there is the right key in the right position
catch (System.Exception e)
{
Log(e);
}
//////************************************************** ***
We have some subkey below "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.wax"
But after the operation the rk still equal to null and there isn't any
exception.

Has someone met the same situation?
Nov 16 '06 #3

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

Similar topics

10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
3
by: Eric the half a Bee | last post by:
Hello I am trying to implement a search function within a collection of Employees. I am searching for a specific EmpID number in the collection, and if it is found, I want to return the...
1
by: Rudy Meijer | last post by:
Hello, I made a class which read a key from the registry. This class is called every second in a timer event. Everything works fine but the class leaks memory. about 4Kb/s taskmanager. ...
5
by: Steve Bottoms | last post by:
Hi, all... Trying to determine how to check the state of OpenSubKey when called. What is the return value if the requested subkey doesn't exist?? I try a GetType on the result but only get a...
11
by: joey.powell | last post by:
Hello, I have a windows forms application (VS2005) where I need to do the following... 1. Startup with a main form. 2. Have the user to select a file and then bring up a second form modally...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
68
by: Jim Langston | last post by:
I remember there was a thread a while back that was talking about using the return value of a function as a reference where I had thought the reference would become invalidated because it was a...
3
by: thephatp | last post by:
This is incredibly strange. I used regedit and went to HKEY_LOCAL_MACHINE and create a new subkey under "Software". I added a few more, then went into code to try to read them. I kept getting...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.