Read the program from the registry

zhaozj2021-02-16  56

Read the program from the registry

Sunhai

Development Tools: Microsoft Visual Studio .NET 2003 operating system: Windows XP

Introduction to Registry

Read and write the registry in Visual Studio .NET to generally use the Registry class.

The Registry class provides the standard root set found in the registry on the registry running Windows. The registry is a storage device that contains information about applications, users, and default system settings. For example, an application can use a registry to store information that needs to be retained after the application is shut down, and accesses those the same information when the application is reloaded. For example, you can store color preferences, screen positions, or window sizes. This information can be controlled for each user by storing information in different locations in the registry.

The base (root) RegistryKey instance disclosed by Registry, depicts the basic storage mechanism of the child and value in the registry. All items are read-only because the registry relies on their existence. The items disclosed by the registry are: Currentuser stores information about the user's preferences. LocalMachine stores the configuration information of the local computer. Classessroot stores information about types (and classes) and their properties. Users store information about the default user configuration. PerformAncedata stores performance information for software components. CurrentConfig stores non-user-specific hardware information. Dyndata stores dynamic data.

Once you want to use the REGISTRYKEY class to add or remove the value of the child and the value of the subkey and the value of the operation.

Hardware devices can be automatically placed in the registry using a plug-and-play interface. The software to install the device driver can be placed in the registry by writing information to the standard API.

RegistryKey class

The RegistryKey class represents an item-level node in the Windows registry. This type is a registry package.

The registry acts as a central information repository for operating systems and applications on your computer. The registry is organized in a layered form based on the logical order of the elements stored therein (see registry) for groups in the hierarchy. When storeing information in the registry, select the appropriate location based on the stored information type. Be sure to avoid damaging information created by other applications, because this will result in unexpected behavior of applications, and will also adversely affect your own application.

RegistryKeys is the basic organizational unit in the registry, which is like it is a folder in the Windows Explorer. The specific item can have a child (like the folder can have a subfolder), and this item can be deleted as long as the user has the appropriate delete permissions and this item is not the next level of the standard or standard. Each item can also have multiple associated values ​​(value comparison is file), which is used to store information for applications you are interested. Save each value to retrieve or update this information when needed. For example, you can create a registryKey for your company (under the item HKEY_LOCAL_MACHINE / SOFTWARE) and then create a child for each application created by your company. Each child holds information specific to the application, such as color settings, screen positions, or identifiable file extensions.

Note that the information stored in the registry can be used by other applications and users, so it is not necessary to store security information or critical application information with registry.

To get an instance of RegistryKey, use a static member OpenSubkey or use a static member of the Registry class.

This article mainly uses: registryKey.opensubkey method: Retrieve the specified child with the specified write access.

Retrieve the subkey in read-only mode.

[Visual Basic] Overloads Public Function OpenSubkey (String) AS RegistryKey RegistryKey.getsubKeynames method: Retrieves an array of strings containing all child names. Public Function GetSubKeynames () AS String () Reads Excel from the registry

First introduced the namespace: Imports system imports microsoft.win32 To know about the registry, know the location we have to read in HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Office.

Dim rk As RegistryKey = _ Registry.LocalMachine.OpenSubKey ( "Software / Microsoft / Office", True) 'Get the data from a specified item in the key. Dim s As String () = rk.GetSubKeyNames () Dim blnExcel As Boolean = False 'Notle installed Excel Dim Excelver AS String' Excel's version of for Num as integer = 0 to S.Length - 1 Select Case S.GetValue (NUM) Case "11.0", "9.0", "8.0", "5.0", "4.0", "3.0" 'Excel Dim rk1 as registryKey = _ registry.localmachine.opensubkey ("Software / Microsoft / Office /" & S.GetValue (NUM) & "/ Excel", TRUE ) IF not (rk1 is nothing) THEN BLNEXCEL = true excelver = s.getvalue (num) EXIT SELECT EXIT for end if End SelectNext

Is it very easy to read and write a registry using the RegistryKey class?

May 3, 2004

My QQ: 26624998 My website: http://blog.9cbs.net/2066/

转载请注明原文地址:https://www.9cbs.com/read-22807.html

New Post(0)