Thread: Getting other mudule paths

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    Getting other mudule paths

    Hi!

    I want to get file paths of other modules running on my computer using GetModuleFileName(), but don't really know how to do it. Anyone know any helpfull lessons/tutorials please?

    Thanks.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    You can use the Process32First/Process32Next functions.

  3. #3
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    Thanks.

    Though I'm having some troubles. I have the below code up to now:

    Code:
    ......
    ......
    HANDLE hProcSnap = NULL;
    PROCESSENTRY32 pe32;
    MODULEENTRY32 me32;
    
    hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    if(hProcSnap==INVALID_HANDLE_VALUE) ErrHandler();
    		
    pe32.dwSize=sizeof(PROCESSENTRY32);
    me32.dwSize=sizeof(MODULEENTRY32);
    
    if(Process32First(hProcSnap,&pe32))
    {
       do
       {
           Module32First(hProcSnap,&me32);
           strcpy(fpth,me32.szExePath);
       }while(Process32Next(hProcSnap,&pe32));
    }
    else
    {
       ErrHandler();
    }
    ......
    ......
    I'm trying to step through each process and get their module paths. But me32.szExePath returns nothing. please show me my fault.

    Thanks.

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Seems you need to create a snapshot for each process:
    Example

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ignore paths???
    By gransken in forum C++ Programming
    Replies: 12
    Last Post: 11-29-2008, 05:30 AM
  2. Platform independent paths
    By zacs7 in forum C Programming
    Replies: 6
    Last Post: 11-22-2008, 09:51 AM
  3. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  4. Finding the number of different paths on a rectangular grid
    By joejoefla in forum C++ Programming
    Replies: 3
    Last Post: 03-14-2004, 02:13 PM
  5. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 09:28 AM