Registry Properties and Key Names in Visual Studio .NET

Generator QR Code in Visual Studio .NET Registry Properties and Key Names
Table 112 Registry Properties and Key Names
Paint QR Code In .NET
Using Barcode maker for .NET Control to generate, create Quick Response Code image in Visual Studio .NET applications.
Registry Class Static Property RegistryClassesRoot RegistryCurrentConfig RegistryCurrentUser RegistryDynData RegistryLocalMachine RegistryPerformanceData RegistryUsers
QR Code JIS X 0510 Reader In .NET Framework
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET applications.
Registry Hive Key Name HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER HKEY_DYN_DATA[a] HKEY_LOCAL_MACHINE HKEY_PERFORMANCE_DATA HKEY_USERS
Bar Code Creation In .NET
Using Barcode drawer for .NET Control to generate, create bar code image in VS .NET applications.
Win9x only
Bar Code Recognizer In VS .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
To use the Registry to store settings, Microsoft recommends putting them under the hive key using the following format: <hiveKey>\Software\<companyName>\<productName>\<productVersion> Here's an example: HKEY_CURRENT_USER\Software\Sells Brothers, Inc\My Settings Test\10112431077 The variable values are, coincidentally, exactly the same values provided by ApplicationCompanyName, ApplicationProductName, and ApplicationVersion, so you can construct a top-level key name by using the following: string appkey = stringFormat( @"Software\{0}\{1}\{2}", ApplicationCompanyName, ApplicationProductName, ApplicationProductVersion); using( RegistryKey key = RegistryLocalMachineOpenSubKey(appkey) ) { } Similarly, for roaming user settings, Microsoft recommends using the same subkey but under the HKEY_CURRENT_USER hive instead of the HKEY_LOCAL_MACHINE hive To accommodate the many people desiring to open subkeys for application and roaming user settings in the Microsoftrecommended spots, the WinForms Application object includes two properties that provide preopened registry keys at the right spot depending on whether you'd like application data or roaming user data These properties are named CommandAppDataRegistry and UserAppDataRegistry For example, to save the main form's position you could use the UserAppDataRegistry key: void MainForm_Closing(object sender, CancelEventArgs e) { // Save the form's position before it closes using( RegistryKey key = ApplicationUserAppDataRegistry ) { // Restore the window state to save location and // client size at restored state FormWindowState state = thisWindowState; thisWindowState = FormWindowStateNormal;
Encode QR Code In Visual C#.NET
Using Barcode creator for VS .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications.
keySetValue("MainFormLocation", ToString(thisLocation)); keySetValue("MainFormClientSize", ToString(thisClientSize)); keySetValue("MainFormWindowState", ToString(state)); } } // Convert an object to a string string ToString(object obj) { TypeConverter converter = TypeDescriptorGetConverter(objGetType()); return converterConvertToString(obj); } This example uses the Closing event to notice when the main form is about to close (but before it does) to save the window state, location, and client size In addition to remembering to restore the window state before saving the location and the client size, this code uses the ToString helper function This function uses a type converter, which is a helper to aid in the conversion between instances of a type and strings (for more on type converters, see 9: Design-Time Integration) Any type can have an associated type converter, and most of the simple ones do After the application is run once, notice the settings that are saved in the Registry, as shown in Figure 1110
Making QR Code 2d Barcode In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
Figure 1110 Using the Registry for User Settings
QR Code Creation In Visual Basic .NET
Using Barcode maker for Visual Studio .NET Control to generate, create QR image in Visual Studio .NET applications.
Notice that the size is shown as "292, 54" instead of "{292, 54}," as would have happened if we had used the built-in Size class's ToString method Because Size's type converter doesn't know how to translate the surrounding braces, it's important to use the type converter's conversion to the string format instead of the type's conversion to ensure that the value can be read back during loading of the form: void MainForm_Load(object sender, EventArgs e) { // Restore the form's position using( RegistryKey key = ApplicationUserAppDataRegistry ) { try { // Don't let the form's position be set automatically thisStartPosition = FormStartPositionManual; thisLocation = (Point)FromString( keyGetValue("MainFormLocation"), typeof(Point)); thisClientSize = (Size)FromString( keyGetValue("MainFormClientSize"), typeof(Size));
Data Matrix 2d Barcode Generation In VS .NET
Using Barcode creation for .NET framework Control to generate, create Data Matrix ECC200 image in Visual Studio .NET applications.
thisWindowState = (FormWindowState)FromString( keyGetValue("MainFormWindowState"), typeof(FormWindowState)); } // Don't let missing settings scare the user catch {} } } // Convert a string to an object object FromString(object obj, Type type) { TypeConverter converter = TypeDescriptorGetConverter(type); return converterConvertFromString(objToString()); } In this case, the form's Load method uses the Registry key to load the settings that it saved during the Closing event, this time using the type converters to convert from a string to the appropriate type Notice also that the Load method uses a try-catch block to wrap the attempts to pull values from the Registry; in this way, we avoid throwing an exception if the values aren't present These values typically are missing when the application is first run If you'd like, you can set defaults to avoid the exception when a value is not found: thisWindowState = (FormWindowState)FromString( keyGetValue("MainFormWindowState", "Normal"), typeof(FormWindowState)); Although the Registry can be used for application and user settings, its use has fallen out of fashion Corruption issues with early implementations of the Registry have given it a bad reputation There's nothing inherently wrong with it that more modern versions of Windows haven't fixed long ago However, because the Registry doesn't support nonroaming user settings or use from partially trusted applications, you'll want to consider special folder-based settings media, discussed next
Encode Barcode In VS .NET
Using Barcode generator for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.
Code 128 Code Set A Generator In VS .NET
Using Barcode generator for .NET framework Control to generate, create USS Code 128 image in Visual Studio .NET applications.
MSI Plessey Encoder In Visual Studio .NET
Using Barcode encoder for .NET framework Control to generate, create MSI Plessey image in VS .NET applications.
EAN-13 Supplement 5 Maker In Java
Using Barcode creator for Java Control to generate, create GS1 - 13 image in Java applications.
Create Code 128 Code Set A In C#
Using Barcode creator for VS .NET Control to generate, create USS Code 128 image in .NET applications.
Decode Barcode In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Paint Barcode In Visual C#
Using Barcode creation for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.