Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# loop through the registry searching for keys containing


// 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: #loop #registry #searching #keys
ADD COMMENT
Topic
Name
5+6 =