C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Registry handling


Posted Date: 14 Jul 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Siju.CMember Level: Silver    
Rating: 1 out of 5Points: 5



Reading the keys


RegistryKey rstryKey = Registry.LocalMachine;
RegistryKey rgstryKeyValues = rstryKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion");

Response.Write("ProductId = " + rgstryKeyValues.GetValue("ProductId"));
Response.Write("
");

Response.Write("ProgramFilesDir = " + rgstryKeyValues.GetValue("ProgramFilesDir"));
Response.Write("
");

Response.Write("ProgramFilesPath = " + rgstryKeyValues.GetValue("ProgramFilesPath"));
Response.Write("
");

Response.Write("MediaPath = " + rgstryKeyValues.GetValue("MediaPath"));
Response.Write("
");

rgstryKeyValues.Close();

Writting a registry key
	
rstryKey = Registry.CurrentUser;
rgstryKeyValues = rstryKey.OpenSubKey("SOFTWARE");
RegistryKey rgstrySetKey = rgstryKeyValues.CreateSubKey("TestKeyDirectory");
rgstrySetKey.SetValue("Key1","Key1Value");
rgstrySetKey.SetValue("Key2","Key2Value");
rgstrySetKey.SetValue("Key3",3);




Responses

Author: Patel Akhilkumar Punambhai    24 Aug 2004Member Level: Bronze   Points : 0
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'RegistryKey' is not declared.

Source Error:



Line 11: txtvalue.visible="true"
Line 12:
Line 13: RegistryKey rstryKey = Registry.LocalMachine;
Line 14: RegistryKey rgstryKeyValues = rstryKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion");
Line 15:




Author: R. Hari Hara Madavan    11 Oct 2004Member Level: Bronze   Points : 0
Hi,

Please Import Microsoft.Win32 namespace for the above code to work.

VB.NET:

Imports Microsoft.Win32

C#:

using Microsoft.Win32;


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Different types of files involved in ASP.NET project
Previous Resource: How to maintain the session in sql server
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use