hi everybody
i have a small problem
i want to access to registre with a localsystem service to check a key value (to check if the usb is activated or not)
i dont know if there is a probleme with permissions(session,currentuser) but i want my service to be independent from the user session
i tried this but it doesn t work:
RegistryKey mycle = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Service\USBSTORE", false);
var cle = Registry.GetValue(@"SYSTEM\CurrentControlSet\Service\USBSTORE", "start", -1);
first i know that the value is 3 or 4 to check if the usb is activated but i dont know how to cast the return type of getvalue
i also dont know if the method opensubkey is better than this
int cle = (int)Registry.GetValue(@"SYSTEM\CurrentControlSet\Service\USBSTORE", "start", -1);
i found something like this (should i use it??) : if (Environment.Is64BitOperatingSystem)
{
localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
}
else
{
localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
}
please help me...