Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

How to search values in the registry


// Below is a sample code that illustrates how to query for a given
// Value 'VisualStudio' in the HKLMSOFTWAREMicrosoft tree.


using System;
using System.Runtime.InteropServices;
using LogQuery = Interop.MSUtil.LogQueryClass;
using RegistryInputFormat = Interop.MSUtil.COMRegistryInputContextClass;
using RegRecordSet = Interop.MSUtil.ILogRecordset;

class Program
{
	public static void Main()
	{
		RegRecordSet rs = null;
		try
		{
			LogQuery qry = new LogQuery();
			RegistryInputFormat registryFormat = new RegistryInputFormat();
			string query = @"SELECT Path from HKLMSOFTWAREMicrosoft where
			Value='VisualStudio'";
			rs = qry.Execute(query, registryFormat);
			for(; !rs.atEnd(); rs.moveNext())
				Console.WriteLine(rs.getRecord().toNativeString(","));
		}
		finally
		{
			rs.close();
		}
	}
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #search #values #registry
ADD COMMENT
Topic
Name
7+7 =