Saturn Software Mills Visit for more technical article http://www.saturnsoftmills.com
What is Windows Registry : Programmers Perspective Your computer runs different kind of processes either system or application specific. These processes need to store their current state, user defined variables etc. somewhere. In the early days, Windows used the concept of .INI files. These files were keeping the desired data by an application. Since the evolution of Windows 95 onward, Microsoft started a new concept – Windows Registry. The registry can be thought as a structured database that can store system, application specific information in to it. More precisely we can say that Registry is data tree that stores the information in a hierarchical fashion. Each node in this tree is called a KEY and each KEY further contains SUBKEYS and data entries or values. The windows registry has a minimum predefined structure. It contains at a minimum four KEYS as written under. HKEY_CLASSES_ROOT All the subkeys under this node will have the information about all the defined classes and document types and the properties associated with them. Generally Windows shell applications and OLE based applications make use of this information. HKEY_CURRENT_USER The keys under this node contain information, settings and preferences of the current user logged in to the machine. HKEY_LOCAL_MACHINE The keys under this node contain the complete information about your computer hardware and software. HKEY_USERS Registry entries under this node contain the default configuration for new user login on the computer. When an application software needs to add data in to the registry, it tries to get the handle of the desired KEY and then add the desired data under it. You must be aware that the key names in the registry should not contains white spaces, backslash or wildcard characters. The key names should also not start with the period (.) as this is reserved for the file name extensions under HKEY_CLASSES_ROOT. In the registry, a key can have many values. Each entry consists of three parts – name, value’s data type and the actual value. To start working with the registry, you must know the function calls related to the windows registry. Some of the functions provided by the Win32 are listed below. The complete list can be studied from MSDN. RegCreateKey( ) Creates a key if it does not exist otherwise open the specified key (for 16-bit windows).
Saturn Software Mills Visit for more technical article http://www.saturnsoftmills.com
RegCreateKeyEx( ) Creates a key if it does not exist otherwise open the specified key (for 32-bit windows). RegCloseKey( ) Releases the handle of the specified key. RegDeleteKey( ) Deletes the specified key. The key should not have any subkey under it otherwise it fails. RegOpenKey( ) Opens the specified key (16-bit Windows). RegOpenKeyEx( ) Opens the specified key (32-bit Windows). RegQueryInfoKey( ) Gets information about the specified key. RegQueryValue( ) Retrieve the value of the specified key (16-bit Windows). RegQueryValueEx( ) Retrieve the value of the specified key (32-bit Windows). RegSaveKey( ) Save the specified key and all its subkeys and values in to a file. RegSetValue( ) It sets a value to the specified key. RegDeleteValue( ) Removes a named value from the registry. RegEnumKey( ) Enumarets the subkeys of the specified open registry key. It retrieves the name of the subkeys every time it is called (16-bit Windows). RegEnumKeyEx( ) Enumarets the subkeys of the specified open registry key. It retrieves the name of the subkeys every time it is called (32-bit Windows). The functions listed above are the main functions that are used in general. The Win32 supports some other function calls also. If interested, you must refer the MSDN for it. To see the registry of your computer run the command “regedit” either from command prompt or from the “Run” option in the start menu of your computer. I personally suggest you not to disturb any registry entry otherwise your computer may start misbehaving.