473,804 Members | 3,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
this.target);
try
{
rk = rkHive.OpenSubK ey(oro.key.Valu e);
//rkHive = {HKEY_LOCAL_MAC HINE}
//oro.key.Value=" \\SOFTWARE\\Cla sses\\.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.Excepti on e)
{
Log(e);
}
//////*************** *************** *************** ********
We have some subkey below "HKEY_LOCAL_MAC HINE\\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 2072
Hi Leo,

When you open a SubKey, you must not have the preseding //. In your case
oro.key.Value should be SOFTWARE\\Class es\\.wax, not
\\SOFTWARE\\Cla sses\\.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.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
this.target);
try
{
rk = rkHive.OpenSubK ey(oro.key.Valu e);
//rkHive = {HKEY_LOCAL_MAC HINE}
//oro.key.Value=" \\SOFTWARE\\Cla sses\\.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.Excepti on e)
{
Log(e);
}
//////*************** *************** *************** ********
We have some subkey below "HKEY_LOCAL_MAC HINE\\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\\Class es\\.wax, not
\\SOFTWARE\\Cla sses\\.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.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
this.target);
try
{
rk = rkHive.OpenSubK ey(oro.key.Valu e);
//rkHive = {HKEY_LOCAL_MAC HINE}
//oro.key.Value=" \\SOFTWARE\\Cla sses\\.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.Excepti on e)
{
Log(e);
}
//////*************** *************** *************** ********
We have some subkey below "HKEY_LOCAL_MAC HINE\\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
42428
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 to be optional, it's very definition is it's a necessary link to the parent table and part of the definition. If it's optional it shouldn't be part of the definition of a table and should be in a linking table instead. Comments?
3
5878
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 Employee. This I can do. The problem comes if the EmpID is not found in the collection. The only way to achieve this I can think of is to throw an invalid argument exception:
1
2448
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. public class runKey: IDisposable { RegistryKey rk;
5
4674
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 bizarre error, so I'm uncertain what should be returned on both success or failure! Thanks! Jack
11
3255
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 (Form1.ShowDialog()) so that the user can make custom selections. 3. I can store the selections from the second form in many different
18
4068
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
4660
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 temporary but it was stated that it would not. This has come up in an irc channel but I can not find the original thread, nor can I get any code to work. Foo& Bar( int Val ) { return Foo( Val ); }
3
23773
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 null returned when I tried to open them, so I decided to try this: Registry.LocalMachine.GetSubKeyNames() The results where dumbfounding--they did NOT match what I see in the Registry under HKEY_LOCAL_MACHINE. The list values returned from the...
2
3882
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 stated. Also please note that this is unrelated to another of my previous threads, “dataAdapter.Update problem”, which incidentally has been resolved. I’m learning SQL. I’m accessing database SQL2008 AdventureWorks, table Person.Contact, which has a...
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.