Sunday, November 23, 2008

Tips to improve computer performance - Windows XP

Tips to improve computer performance - XP
  1. Start->Run “msconfig”in the startup tab, uncheck services that’s not needed anc click on “save” the settings. Restart system
  2. Win XP has got a service “Indexing Service” that’s does no big deal in Win XP. Right-click on the service and make it a manual start or disable it
  3. Right-Click My Computer and select properties. Go on to Advanced Tab and select “settings” in “Performance” section, in “Visual Effects” tab
  4. Click on “Adjust for best performance”
  5. Right-Click My Computer and select properties. Go on to Advanced Tab and select “settings” in “Performance” section, in “Advanced” tab
  6. Click on the “change” button in “Virtual Memory” group box
  7. Set Initial size to be the same as Maximum Size
  8. Click on the button “Set”
  9. Click on OK


Reviving system from Virus Infections
  1. Ensure you have a good Anti Virus + Any spyware + Any Malware software
  2. Make sure it is constantly updated

Some ways to identify and correct issues
  1. Delete all files from C:\Quarantine
  2. Clear all cookies
  3. Clear History
  4. Download utilities like Trojan Remover, Spy Hunter and Easy Cleaner applications
  5. Start->Run “msconfig”in the startup tab, go to the “startup” tab
  6. Uncheck all items that look like Rundll32.exe "C:\xyz...dll
Awarness - Keep track of what's getting downloaded
  1. Keep watching for dll files downloaded in the directory c:\windows\system32 and c:\windows\system. If you feel any suspicious dll's, delete them immediately
  2. If you find a dll that you suspect to be a VIRUS, try deleting it. If you are not able to, check to see, if it's from a legitimate publisher. If you still suspect, check to see, if this dll has attached itself to the startup process (through "msconfig" utility). If yes, uncheck the dll from startup process
  3. Open regedit, and remove entries from on of the following locations HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg and
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  4. Rename the dll's to some other file, Restart your system and delete the renamed files

Monday, November 10, 2008

A simple Event handler in C#

A simple example to show event handling mechanism in C#.

Here We perform addition operation. A new class Addition has been created for this purpose. Class Addition has 2 fields Num1, Num2, and both are integers(as expected).

2 events have been defined,
Add complete event and
Add Failed event

Add complete event, does not take any arguments, while add failed event should respond back with failure and error message

Implementation is rudimentry. My rule is, Num1 and Num2 should not be 0 for successful summation, even if one of them is zero, failure event is raised

program.cs is appended

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;

namespace ExRegistryMonitor
{
class Program
{
static void Main(string[] args)
{
Addition add = new Addition(0, 20);
add.addComplete += new EventHandler(add_addComplete);
add.addFailed += new EventHandler(add_addFailed);
int sum = add.Add2Integers();
Console.WriteLine("Sum of 2 numbers :" + sum);
Console.ReadKey(true);
}

static void add_addFailed(object sender, EventArgs e)
{
AdditionEventArgs e1 = (AdditionEventArgs)e;
Console.WriteLine("Failed :" + e1.Message);
}

static void add_addComplete(object sender, EventArgs e)
{
Console.WriteLine("Add completed");
}

}
}

Addition.cs is appended

using System;
using System.Collections.Generic;
using System.Text;

namespace ExRegistryMonitor
{
class Addition : IDisposable
{
#region Addition Members
private int num1;

public int Num1
{
get { return num1; }
set { num1 = value; }
}
private int num2;

public int Num2
{
get { return num2; }
set { num2 = value; }
}
#endregion

#region IDisposable Members
public void Dispose()
{
//do nothing
}
#endregion

#region constructors
public Addition()
{
num1 = num2 = 0;
}

public Addition(int num1)
{
this.num1 = num1;
}

public Addition(int num1, int num2)
{
this.num1 = num1;
this.num2 = num2;
}
#endregion

public event EventHandler addComplete;
public event EventHandler addFailed;
public delegate void sumFailed(object sender, AdditionEventArgs e);

public virtual void OnAddComplete()
{
EventHandler eventHandler = addComplete;
if (addComplete != null)
addComplete(this, null);
}

public virtual void OnAddFailed(object sender, AdditionEventArgs e)
{
EventHandler eventHandler = addFailed;
if (addFailed != null)
addFailed(this, e);
}

public int Add2Integers()
{
int sum = 0;
sum = num1 + num2;
if (num1 == 0 || num2 == 0)
{
AdditionEventArgs e = new AdditionEventArgs();
if (num1 == 0)
e.Message = "NUM1 is 0";
else
e.Message = "NUM2 is 0";
e.Sum = sum;
OnAddFailed(this, e);
return 0;
}
OnAddComplete();
return sum;
}
}

public class AdditionEventArgs : EventArgs
{
private string sMessage;
private int nSum;

public int Sum
{
get { return nSum; }
set { nSum = value; }
}

public string Message
{
get { return sMessage; }
set { sMessage = value; }
}
}
}