I have a code like this
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Data.Odbc;
using System.Text;
using System.Data;
using Microsoft.Win32;
using System.IO;
using System.Diagnostics;
using System.Net;
public class sylagent : Form
{
private Process[] myproc;
private Timer t1;
private FileVersionInfo myinfo;
private int count;
private System.ComponentModel.Container components = null;
private String program;
public sylagent()
{
myproc = Process.GetProcesses();
count = 0;
this.Size = new Size(300, 300);
this.Location = new Point(100, 100);
this.Visible = false;
this.t1 = new Timer();
this.t1.Interval = 1000;
this.t1.Start();
this.t1.Tick += new EventHandler(t1_tick);
}
protected override void Dispose(bool Disposing)
{
if (Disposing)
{
if (components != null)
{
components.Dispose();
}
}
Process[] procuo = Process.GetProcesses();
for (int i = 0; i < procuo.Length; i++)
{
if
(procuo[i].ProcessName.Equals("client"))
{
procuo[i].Kill();
}
}
base.Dispose(true);
}
public void t1_tick(object sender, EventArgs e)
{
for (int i = 0; i < myproc.Length; i++)
{
if (this.myproc[i].MainModule.FileName !=
null)
{
this.program =
this.myproc[i].MainModule.FileName.ToString();
}
if (this.program[0] == 'C' ||
this.program[0] == 'D' || this.program[0] == 'E' ||
this.program[0] == 'F' || this.program[0] ==
'G')
{
this.myinfo =
FileVersionInfo.GetVersionInfo(this.myproc[i].MainModule.FileName.ToString());
}
if
(this.myinfo.OriginalFilename.ToString().Equals("c onnector.exe"))
{
this.count++;
}
}
if (this.count != 1)
{
this.Close();
}
this.count = 0;
}
public static void Main()
{
Application.Run(new sylagent());
}
}
and when i execute my program i m taking this error
[code:1:dcfdf8a81c]
object reference not set to an instance of an object
[/code:1:dcfdf8a81c]
How can i fix it
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com