I have a code like this and when i execute my program im taking this
error
unable to enumarate the process module
and here is my code
[code:1:628af64716]
public bool proccescheck()
{
int count=0;
MyCmd = new OdbcCommand();
MyConn = new OdbcConnection("DRIVER={MySQL ODBC
3.51 Driver};" + "SERVER=localhost;" +
"DATABASE=connector;" + "UID=root;" +
"PWD=root;");
MyConn.Open();
MyCmd.Connection = MyConn;
StringBuilder procheckbuild = new StringBuilder();
procheckbuild.Append("select name,memory from
programlar");
MyCmd.CommandText = procheckbuild.ToString();
OdbcDataReader procheck =
MyCmd.ExecuteReader(CommandBehavior.CloseConnectio n);
while(procheck.Read())
{
count++;
}
procheck.Close();
Process[] myproc = Process.GetProcesses();
for (int i = 0; i < myproc.Length-4; i++)
{
String procname = myproc[i].ProcessName;
String dir =
myproc[i].MainModule.FileName.ToString();
if (dir[0] == 'C' || dir[0] == 'D'
|| dir[0] == 'E' || dir[0] == 'F' || dir[0] ==
'G' || dir[0] == 'H')
{
myinfo =
FileVersionInfo.GetVersionInfo(dir);
}
for (int j = 1; j <= count; j++)
{
MyCmd = new OdbcCommand();
MyConn = new
OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};" + "SERVER=localhost;" +
"DATABASE=connector;" + "UID=root;" +
"PWD=root;");
MyConn.Open();
MyCmd.Connection = MyConn;
StringBuilder proceskontrol = new
StringBuilder();
proceskontrol.Append("select name,memory
FROM programlar where id ='");
proceskontrol.Append(j);
proceskontrol.Append("'");
MyCmd.CommandText =
proceskontrol.ToString();
OdbcDataReader prochecking =
MyCmd.ExecuteReader(CommandBehavior.CloseConnectio n);
while (prochecking.Read())
{
String program =
prochecking.GetString(0);
String memorysize =
prochecking.GetString(1);
int memory = int.Parse(memorysize);
if (myinfo.OriginalFilename != null)
{
if
(myinfo.OriginalFilename.Equals(program) ||
myproc[i].PrivateMemorySize64 == memory)
{
return false;
}
}
}
MyConn.Close();
}
}
return true;
}
[/code:1:628af64716]
how can i fix it ?
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com