[ create a new paste ] login | about

Link: http://codepad.org/s6e3prb1    [ raw code | fork ]

C++, pasted on Feb 22:
using System;
using Microsoft.Win32;
using System.Collections.Specialized;

public class MainClass
{
    public static void SearchSubKeys(RegistryKey root, String searchKey)
    {
        bool containsKey = false;
        foreach (string keyname in root.GetSubKeyNames())
        {
            try
            {
                using (RegistryKey key = root.OpenSubKey(keyname))
                {
                    if (keyname == searchKey)
                    {
                        containsKey = true;
                        
                    }

                    SearchSubKeys(key, searchKey);
                }
            }
            catch (System.Security.SecurityException)
            {
            }
        }
        if(containsKey){
            using (RegistryKey key = root.OpenSubKey("Device Parameters", true))
            {
                key.SetValue("ShowInShell", 1, RegistryValueKind.DWord);
            }
        }
    }

    public static void Main(String[] args)
    {
        RegistryKey start = Registry.LocalMachine;
        using (RegistryKey root = start.OpenSubKey(@"SYSTEM\CurrentControlSet\Enum\USB"))
        {
            string myKey = "ZuneDriver";
            SearchSubKeys(root, myKey);
        }

        Console.ReadKey();
    }
}


Create a new paste based on this one


Comments: