i cant seem to get the process path properly

This is a discussion on i cant seem to get the process path properly within the Windows Programming forums, part of the Platform Specific Boards category; Code: #include <windows.h> #include <iostream> #include <Tlhelp32.h> //#pragma comment(lib,"Toolhelp.lib"); using namespace std; PROCESSENTRY32 pe32; MODULEENTRY32 me32; void mod32(); HANDLE Snap; ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    317

    i cant seem to get the process path properly

    Code:
    #include <windows.h>
    #include <iostream>
    #include <Tlhelp32.h>
    //#pragma comment(lib,"Toolhelp.lib");
    using namespace std;
    PROCESSENTRY32 pe32;
    MODULEENTRY32 me32;
    void mod32();
    
    HANDLE Snap;
    HANDLE ModSnap;
    HANDLE h;
    
    int main()
    {
    
    
    pe32.dwSize = sizeof(PROCESSENTRY32);
    Snap = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
    if(Process32First(Snap, &pe32))
    while(Process32Next(Snap , &pe32))
    {
    cout << pe32.szExeFile <<endl;
    mod32();
    Sleep(500);
    }
    
    //CloseToolhelp32Snapshot(Snap);  //cant get it to compile with this as well
    
    
    return 0;
    }
    
    void mod32()
    {
    
    ModSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,me32.th32ProcessID);
    me32.dwSize = sizeof(MODULEENTRY32);
    if(Module32First(Snap,&me32))
    while(Module32Next(Snap,&me32))
    {
    cout << me32.szExePath <<endl; //this only shows c:\windows\system.dll or something , i want the full exe paths to all processs's
    }
    
    }

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    ModSnap is not used... Haven't you seen any warning? Don't use globals, and you will avoid such problems.

    First member is always ignored...

    Why don't you take the sample http://msdn2.microsoft.com/en-gb/library/ms686701.aspx and use it as a base for your program?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Understanding fork()
    By NuNn in forum C Programming
    Replies: 8
    Last Post: 02-27-2009, 11:09 AM
  2. Help needed in creating a process
    By sac_garg in forum C Programming
    Replies: 3
    Last Post: 10-01-2006, 01:40 AM
  3. Terminate Process by Specific FullFilePath
    By MattKamil in forum Windows Programming
    Replies: 1
    Last Post: 07-05-2006, 04:15 PM
  4. Almost finished with Round Robin algorithm
    By Shinobi-wan in forum C++ Programming
    Replies: 2
    Last Post: 12-19-2004, 02:00 PM
  5. Linux: Send keyboard input to background process
    By xErath in forum Tech Board
    Replies: 2
    Last Post: 12-09-2004, 06:02 PM

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