I am messing about with my Windows Phone after finding and using the registry edit to allow it to be accessed through explorer. My aim is to write a quick console application to perform this registry edit on any machine it is plugged into.
THIS IS THE WINDOWS 7 REGISTRY. NOT THE PHONE Here are the steps I am trying to follow
So far I have written code that will find all instances of device registry entries containing 'ZuneDriver'
RegistryKey start = Registry.LocalMachine;
using (RegistryKey root = start.OpenSubKey(@"SYSTEM\CurrentControlSet\Enum\USB"))
{
string myKey = "ZuneDriver";
SearchSubKeys(root, myKey);
The issue here is that, the registry key 'ZuneDriver' is a subkey of the 'Device Parameters' key I will need to change a value of.
At the moment, the results of the search are stored in:
static System.Collections.Specialized.StringCollection log = new System.Collections.Specialized.StringCollection();
by my search function:
public static void SearchSubKeys(RegistryKey root, String searchKey)
{
foreach (string keyname in root.GetSubKeyNames())
{
try
{
using (RegistryKey key = root.OpenSubKey(keyname))
{
if (keyname == searchKey)
{
log.Add(key.Name);
}
SearchSubKeys(key, searchKey);
}
}
catch (System.Security.SecurityException)
{
}
}
}
A stored result looks like this:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_045E&PID_04EC&MI_00\7&b85dba6&0&0000\Device Parameters\ZuneDriver
I would like to get my program to have registry access to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_045E&PID_04EC&MI_00\7&b85dba6&0&0000\Device Parameters
to edit the value of a DWORD called 'ShowInShell'
but it needs to have determined \VID_045E&PID_04EC&MI_00\7&b85dba6&0&0000\ through the initial search.....
Any pointers or suggestions much appreciated :)
Cheers,
Ben