Thread: Exception when getting module names.

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    404

    Exception when getting module names.

    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
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amateur English)

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    is that C#, because it doesn't look like C/C++? If so you migth have better luck if a mod moves this to the C# channel.

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    404
    Wrote it in C++/CLI using VC++.Net 2005.

    This code doesn't belong to C++ forum?
    Last edited by geek@02; 08-01-2009 at 06:44 AM.
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amateur English)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Find Injected DLLs In A Process?
    By pobri19 in forum Windows Programming
    Replies: 35
    Last Post: 02-06-2010, 08:53 AM
  2. Exception handling in a large project
    By EVOEx in forum C++ Programming
    Replies: 7
    Last Post: 01-25-2009, 06:33 AM
  3. Getting function names from a module
    By Thantos in forum Windows Programming
    Replies: 2
    Last Post: 01-19-2005, 08:52 AM
  4. Function basics
    By sjleonard in forum C++ Programming
    Replies: 15
    Last Post: 11-21-2001, 11:02 AM