473,394 Members | 1,701 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,394 software developers and data experts.

Registry, Close Keys or Not?

I've been accesing the registry in the two following ways:

using (RegistryKey SubKey = Registry.LocalMachine.OpenSubKey(sSubKey + x))

using (RegistryKey Key = Registry.LocalMachine.CreateSubKey(sSubKey + x))

Should I close the Keys after either or both of these actions? Can you
explain the benifits of either action?
Nov 16 '05 #1
1 3137
Yogi_Bear_79,

Well, one is opening a key, the other is creating it. It all depends on
the action you want to take.

As far as the key is concerned, you are using the using statement, so
any resources associated with the instance will be released when the using
block is exited.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:9u********************@comcast.com...
I've been accesing the registry in the two following ways:

using (RegistryKey SubKey = Registry.LocalMachine.OpenSubKey(sSubKey + x))

using (RegistryKey Key = Registry.LocalMachine.CreateSubKey(sSubKey + x))

Should I close the Keys after either or both of these actions? Can you
explain the benifits of either action?

Nov 16 '05 #2

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

Similar topics

3
by: vbMark | last post by:
Hello, In regards to the Registry... Can someone give me an example of how to list an unknown number of subkeys under a key, and put the key names in one column of a listbox, and the key...
5
by: Chakkaradeep | last post by:
Hi all, in my service i added my Registry Programming code,am facing with a problem which am not able to rectify it..the problem is , in the service, the program gets hanged and doesnt move...
1
by: Paul Remblance | last post by:
The following code fails due to security: Dim regKey As RegistryKey Dim strEvent As String Dim index As Integer Dim f As New RegistryPermission(RegistryPermissionAccess.AllAccess,...
1
by: BarryM | last post by:
Hi im tryin to add a key to registry in classes root. Im tryin to put a icon a .pls file that i made in vb 2005 i have tried using the followig code imports microsoft.win32 button1.click...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.