.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> System Registery >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Working with Registry in a Windows Application

Posted By:Ruchi       Posted Date: March 22, 2010    Points: 10    Category: System Registery    URL: http://www.dotnetspark.com  

With My.Computer.Registry Property Developer can access registry of client's PC and can easily manipulate the registry.

Working with the Registry

My.Computer.Registry provides methods and properties that can be used to get and set values in registry keys. To use these properties, you must have Read and Write permission from the RegistryPermissionAccess Enumeration. Any code running with full trust (under the default security policy, this is any code installed on the user's local hard drive) has the necessary permissions to access the registry.

To Set a Registry Value

  1. Create a Windows application.
  2. Add code to set the value, specifying key and value, as in the following code.
    My.Computer.Registry.SetValue _
    ("HKEY_CURRENT_USER\MyTestKey", _
    "MyTestKeyValue","This is a test value.")
  3. Open the registry to verify that the specified value was set.

To Get a Registry Value

  1. Using the previous example, add code to read the value, specifying the path and the name. This code reads the value Name from the key HKEY_CURRENT_USER\Software\MyApp.
    readValue = My.Computer.Registry.GetValue _
    ("HKEY_CURRENT_USER\Software\MyApp", "Name", Nothing)

For more of such intresting stuff check


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend