Exception when getting module names.

This is a discussion on Exception when getting module names. within the Windows Programming forums, part of the Platform Specific Boards category; 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); // ...

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

    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
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    375
    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.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature 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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21