using System;
using Microsoft.Win32;
class MainClass {
public static void Main(String[] args) {
string lastUser;
string lastRun;
int runCount;
lastUser = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\A\C#","", "Nobody");
if (lastUser == null) {
lastUser = "Nobody";
lastRun = "Never";
runCount = 0;
} else {
lastRun = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\A\C#","LastRun", "Never"); runCount = (Int32)Registry.GetValue(
@"HKEY_CURRENT_USER\Software\A\C#","RunCount", 0);
}
Console.WriteLine("Last user name: " + lastUser);
Console.WriteLine("Last run date/time: " + lastRun);
Console.WriteLine("Previous executions: " + runCount);
Registry.SetValue(@"HKEY_CURRENT_USER\Software\A\C#","", Environment.UserName, RegistryValueKind.String);
Registry.SetValue(@"HKEY_CURRENT_USER\Software\A\C#","LastRun", DateTime.Now.ToString(), RegistryValueKind.String);
Registry.SetValue(@"HKEY_CURRENT_USER\Software\A\C#","RunCount", ++runCount, RegistryValueKind.DWord);
}
}
|