Hi i wanted to search through running proccesses and find specific module name.
Code:
String^ exeNm = (String^)Microsoft::Win32::Registry::GetValue("HKEY_CURRENT_USER\\NoRunProg", "",-1);
// Get all processes
array<Process^>^localAll = Process::GetProcesses();
int l = localAll->Length::get();
for(int i=0; i<localAll->Length::get(); i++)
{
ProcessModule^ pm = localAll[i]->MainModule::get();
String^ fileNm = pm->FileName;
if(exeNm == fileNm)
{
MessageBox::Show("Found");
break;
}
}
when i run above code, i get the exception "Unable to enumerate the process modules." at localAll[i]->MainModule::get() call. This might be because it's a system process. How to avoid this exception and get the module name?
Thanx