473,791 Members | 3,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OpenSubKey return null though the key exist

Hi,

I'm trying to open this key
"HKEY_LOCAL_MAC HINE\SOFTWARE\C lasses\Applicat ions", and
"HKEY_CURRENT_U SER\Software\Mi crosoft\Windows \ShellNoRoam\MU ICache" but it
returns me null.

Anyone know why is that so?

Thanks in advance.
--
(^oo^) 百 as pure as snow
Mar 10 '07 #1
1 3561
Hello Han,

I'm using this code:

[TestFixture]
public class Tests {
[Test]
public void Test( ) {
OpenKeyAndCheck (Registry.Local Machine, @"SOFTWARE\Clas ses\Application s");
OpenKeyAndCheck (Registry.Curre ntUser,
@"Software\Micr osoft\Windows\S hellNoRoam\MUIC ache");
}

private void OpenKeyAndCheck (RegistryKey key, string subKeyName) {
RegistryKey subKey = key.OpenSubKey( subKeyName);
Assert.IsNotNul l(subKey);
}
}

I get the first test passed and the second failed - no wonder, the second
key doesn't exist on my machine. So what's the code you're using?
Oliver Sturm
--
http://www.sturmnet.org/blog
Mar 10 '07 #2

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

Similar topics

102
6069
by: junky_fellow | last post by:
Can 0x0 be a valid virtual address in the address space of an application ? If it is valid, then the location pointed by a NULL pointer is also valid and application should not receive "SIGSEGV" ( i am talking of unix machine ) while trying to read that location. Then how can i distinguish between a NULL pointer and an invalid location ? Is this essential that NULL pointer should not point to any of the location in the virtual address...
99
5201
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
1
2447
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
4673
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
2
2072
by: Leo | last post by:
Hey, guys Please see the code below: /////************************************************ RegistryKey rkHive = null; RegistryKey rk = null; string target = "127.0.0.1"; rkHive = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, this.target); try {
13
2916
by: cppquester | last post by:
A colleague told me that there is a rule about good stype that a function in C++ should have only one point of return (ie. return statement). Otherwise there might be trouble. I never heard about it and doubt it. Anybody heard of it? What would be the advantage? Regards, Marc Example:
0
1965
by: Judith Schmidt | last post by:
Hi group, i search a way to change permissions of a registry key, where only the system account have got full rights. It is not stupid to think that this is possible because i am the owner (administrator) of the key and it is possible to change it with regedit32.exe. The following code fails on OpenSubKey() with System.Security.SecurityException: Requested registry access is not allowed
3
23771
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
5268
by: =?Utf-8?B?RGF2aWQgSw==?= | last post by:
I have some C# code I am using to delete a subkey and its tree from the registry however I am running into some issues. At first, I was using the Registry.LocalMachine.DeleteSubKeyTree method and passing it a string like this: SubKeyBase = @"SYSTEM\CurrentControlSet\Enum\"; Registry.LocalMachine.DeleteSubKeyTree(SubKeyBase + InstanceID); The variable InstanceID had something like this in it:
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10207
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...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
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
7537
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
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5435
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...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
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.