By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,482 Members | 3,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,482 IT Pros & Developers. It's quick & easy.

Unable to enumarete the process module

P: n/a
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
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more C# / C Sharp Questions on Bytes