hi everybody,
i want to write a windows service to list the trusted websites in my computer
for this, i have to open the key at the right path and then list the subkeys.
here is my code but it gives me an exception:
protected override void OnStart(string[] args)
{
RegistryKey localKey;
if (Environment.Is64BitOperatingSystem)
{
localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, RegistryView.Registry64);
}
else
{
localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, RegistryView.Registry32);
}
try
{
RegistryKey mycle = localKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains");
string[] souscle = mycle.GetSubKeyNames();
foreach (string subKeyName in souscle)
{
TextWriter file = new StreamWriter(@"C:\Temp\journal.txt", true);
file.WriteLine("je suis la2" + "\n");
file.WriteLine(subKeyName.ToString() + "\n");
}
}
catch (Exception e)
{
TextWriter file = new StreamWriter(@"C:\Temp\journal.txt", true);
file.WriteLine(e.ToString() + "\n");
file.Close();
}
}
please help i m trying to resolve this problem for lot of days but i can t
thanks