This article is about using Windows Registry functions in C#.Net application. Today I learned some basic functions of registry in Visual Programming Lab. In this example we will learn how to store a value in registry. This example will save the current Height & Width of windows form at Form1_FormClosing event.
First of all we have to add using Microsoft.Win32; in our assemblies because we are using Registry Class of Microsoft.
Creating Event :
Click on Events in properties window
Double click on Form Closing option in Events Window & Automatically Form1_FormClosing Method will be created.
Code for Form1 Closing method.
How to See Stored Values in Registry :
Go to Run & write “RegEdit” & press OK.
Press OK & Registry Window will be Opened.
You can see the values of Height & width stored in Registry.
Here is the output video where I am using Windows Registry for saving Form’s size at closing event & then looking up the size from registry at loading event.
Click on the image below to play Video