Use .NET to read and write Windows registration edit table

xiaoxiao2021-03-06  109

Author: Ranlin warehouse www.ASPCool.com time: 2001-11-9

If you have used the Win32 API function such as Regopenkeyex, RegcreateKeyex, RegcloseKey, you are sure you are familiar with these complex Registry functions. Instead, in the .NET framework, the Registry and RegistryKey classes provide control for Windows registration editing tables, and you can read and write the registration editing table very easily through these classes. These classes are defined in Microsoft.Win32 namespaces and mscorlib.dll assembly, you must use this class before using these classes to declare these namespaces. #using using namespace Microsoft :: Win32; Registry class only seven field members so that you can access seven specific keys in the registration edit table, which is very similar to you open a key in the registration edit table, all of these members Returns a pointer to the registration key. ClassesRoot corresponding HKEY_CLASSES_ROOT CurrentConfig corresponding HKEY_CURRENT_CONFIG CurrentUser corresponding HKEY_CURRENT_USER DynData corresponding HKEY_DYN_DATA LocalMachine corresponding HKEY_LOCAL_MACHINE PerformanceData corresponding HKEY_PERFORMANCE_DATA Users corresponding to read and write data HKEY_USERS HKEY_LOCAL_MACHINE example you want, you can get a pointer to the first key pointer. RegistryKey * pregkey = registry :: localmachine; then call the RegistryKey OpenSubkey member function, and then call GetValue to get a specific string. PregKey-> OpenSubkey (L "Software // Kruse Inc // Version"); Object * pValue = pregKey-> getValue (L "kWise"); if you want to set a key value, you need to call its setValue function.

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

New Post(0)