15.4. Read and Write to the Windows Registry

Problem

You need to read information from, or write information to, the Windows registry.

Solution

Use the methods GetValue and SetValue of the Microsoft.Win32.Registry class.

The GetValue and SetValue methods open a registry key, get or set its value, and close the key each time they are called. This means they are inefficient when used to perform many read or write operations. The GetValue and SetValue methods of the Microsoft.Win32.RegistryKey class, discussed in recipe 15-5, will provide better performance if you need to perform many read or write operations on the registry.

How It Works

The ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.