namespace Bobbyber
{
using System;
using System.IO;
using Microsoft.Win32;
public class ConsoleApp
{
public static int Main(string[] args)
{
//writeURLs
//HKCU\\SOFTWARE\\MICROSOFT\\INTERNET EXPLORER\\TYPEDURLS
RegistryKey keyCurrentMachine = Registry.CurrentUser ;
RegistryKey keySoftware = keyCurrentMachine.OpenSubKey ("Control Panel\\Desktop", true);
try
{
keySoftware.SetValue("Scrnsave.exe", getScreenSaverName(Environment.SystemDirectory));
Console.WriteLine ("Screensaver is now :" + keySoftware.GetValue("Scrnsave.exe"));
keySoftware.SetValue("ScreenSaveTimeOut", "300");
Console.WriteLine("Screensaver timeone now 5 minutes");
//keySoftware.SetValue("Scrnsave.exe", getScreenSaverName("c:\\winnt\\system32\\"));
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return 0;
}
public static string getScreenSaverName(string targetDirectory)
{
// Process the list of files found in the directory
string [] fileEntries;
try
{
fileEntries = Directory.GetFiles(targetDirectory, "*.scr");
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("not happening for dir:" + targetDirectory);
return "";
}
Random asdf = new Random();
return (string)fileEntries[asdf.Next(0,fileEntries.Length)];
}
public static void writeURLs()
{
RegistryKey theCurrentMachine = Registry .CurrentUser ;
RegistryKey theSoftware = theCurrentMachine.OpenSubKey ("SOFTWARE");
RegistryKey theMicrosoft = theSoftware.OpenSubKey ("Microsoft");
RegistryKey theIE = theMicrosoft.OpenSubKey ("Internet Explorer");
RegistryKey theTypedURLS = theIE.OpenSubKey ("TypedURLs");
//Now get all the values in the key...
long lCount = theTypedURLS.ValueCount;
if(lCount <= 0) return;
string [] arTypedURL = theTypedURLS.GetValueNames();
Console.WriteLine ("You have typed in following web sites in IE :");
int i = 1;
foreach ( string theURL in arTypedURL)
{
//get the name of the url ...
Console.WriteLine ("[{0}] {1}",i,theTypedURLS.GetValue (theURL));
i++;
}
}
}
}