Registry, Close Keys or Not?

  • Thread starter Thread starter Yogi_Bear_79
  • Start date Start date
Y

Yogi_Bear_79

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?
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top