Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Track other processes in the computer

Track other processes in the computer

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kamalesh82
    wrote on last edited by
    #1

    Hi All, Currently I'm developing a tool, for that purpose i have to know all other processes running on the computer and achieve the handle of specified process.There are some functions in VB and but i need to write in MFC only... How can get it? bye kamalesh

    kamalesh

    A A H K 4 Replies Last reply
    0
    • K kamalesh82

      Hi All, Currently I'm developing a tool, for that purpose i have to know all other processes running on the computer and achieve the handle of specified process.There are some functions in VB and but i need to write in MFC only... How can get it? bye kamalesh

      kamalesh

      A Offline
      A Offline
      Arman S
      wrote on last edited by
      #2

      See the APIs Process32First, Process32Next from include header <tlhelp32.h>

      -- ===== Arman

      1 Reply Last reply
      0
      • K kamalesh82

        Hi All, Currently I'm developing a tool, for that purpose i have to know all other processes running on the computer and achieve the handle of specified process.There are some functions in VB and but i need to write in MFC only... How can get it? bye kamalesh

        kamalesh

        A Offline
        A Offline
        AkiraOne
        wrote on last edited by
        #3

        See http://msdn2.microsoft.com/en-us/library/ms682629.aspx[^]is helpfuls?

        Too many plans make the health badly!!

        1 Reply Last reply
        0
        • K kamalesh82

          Hi All, Currently I'm developing a tool, for that purpose i have to know all other processes running on the computer and achieve the handle of specified process.There are some functions in VB and but i need to write in MFC only... How can get it? bye kamalesh

          kamalesh

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Does EnumProcesses helpful?


          WhiteSky


          1 Reply Last reply
          0
          • K kamalesh82

            Hi All, Currently I'm developing a tool, for that purpose i have to know all other processes running on the computer and achieve the handle of specified process.There are some functions in VB and but i need to write in MFC only... How can get it? bye kamalesh

            kamalesh

            K Offline
            K Offline
            kasturi_haribabu
            wrote on last edited by
            #5

            Pls Find answer to your code.... I dont know how i can attach a file to code project message. there fore please copy from the message... /* Header File for the Class /* #include "stdafx.h" #include "psapi.h" #pragma pack(16) #define FOUND_WJRU 0 #define WJRU_NOTFOUND 1 class CProcessMonitor { private: DWORD mAvailableProcesses[1024], cbNeeded, cProcesses; public: UINT getTotalAvailableProcesses(); UINT getProcessTimes(); BOOL FindProcessandMemoryDetails(DWORD processID,CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters); BOOL IsProcessMatchingNameAndID( DWORD processID, UINT index ); HANDLE GetProcessHandle(DWORD processID, CString Processname); HANDLE GetHandleToProcess(CString Processname); void GetJRUStatus(int&nStatus, PROCESS_MEMORY_COUNTERS& psMemInfo); }; #pragma pack() /// CPLUSS PLUS FILE.... #include "stdafx.h" #include "psapi.h" #include "EnumProcess.h" BOOL CProcessMonitor::IsProcessMatchingNameAndID( DWORD processID, UINT index ) { char szProcessName[MAX_PATH] = "unknown"; char szTargetProcessName[MAX_PATH] = "Wjru.exe"; PROCESS_MEMORY_COUNTERS psmemCounters; // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName) ); if(strcmp(szProcessName,szTargetProcessName) ==0) { GetProcessMemoryInfo(hProcess,&psmemCounters,sizeof(PROCESS_MEMORY_COUNTERS)); return TRUE; } else { return FALSE; } } } return FALSE; } BOOL CProcessMonitor::FindProcessandMemoryDetails(DWORD processID, CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters) { char szProcessName[MAX_PATH] = "unknown"; char szTargetProcessName[MAX_PATH]; strcpy(szTargetProcessName,Processname.GetBuffer(50)); Processname.ReleaseBuffer(); // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hPro

            H K 2 Replies Last reply
            0
            • K kasturi_haribabu

              Pls Find answer to your code.... I dont know how i can attach a file to code project message. there fore please copy from the message... /* Header File for the Class /* #include "stdafx.h" #include "psapi.h" #pragma pack(16) #define FOUND_WJRU 0 #define WJRU_NOTFOUND 1 class CProcessMonitor { private: DWORD mAvailableProcesses[1024], cbNeeded, cProcesses; public: UINT getTotalAvailableProcesses(); UINT getProcessTimes(); BOOL FindProcessandMemoryDetails(DWORD processID,CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters); BOOL IsProcessMatchingNameAndID( DWORD processID, UINT index ); HANDLE GetProcessHandle(DWORD processID, CString Processname); HANDLE GetHandleToProcess(CString Processname); void GetJRUStatus(int&nStatus, PROCESS_MEMORY_COUNTERS& psMemInfo); }; #pragma pack() /// CPLUSS PLUS FILE.... #include "stdafx.h" #include "psapi.h" #include "EnumProcess.h" BOOL CProcessMonitor::IsProcessMatchingNameAndID( DWORD processID, UINT index ) { char szProcessName[MAX_PATH] = "unknown"; char szTargetProcessName[MAX_PATH] = "Wjru.exe"; PROCESS_MEMORY_COUNTERS psmemCounters; // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName) ); if(strcmp(szProcessName,szTargetProcessName) ==0) { GetProcessMemoryInfo(hProcess,&psmemCounters,sizeof(PROCESS_MEMORY_COUNTERS)); return TRUE; } else { return FALSE; } } } return FALSE; } BOOL CProcessMonitor::FindProcessandMemoryDetails(DWORD processID, CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters) { char szProcessName[MAX_PATH] = "unknown"; char szTargetProcessName[MAX_PATH]; strcpy(szTargetProcessName,Processname.GetBuffer(50)); Processname.ReleaseBuffer(); // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hPro

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              kasturi_haribabu wrote:

              I dont know how i can attach a file to code project message

              Not yet,but you can use of pre when post a code.;)


              WhiteSky


              1 Reply Last reply
              0
              • K kasturi_haribabu

                Pls Find answer to your code.... I dont know how i can attach a file to code project message. there fore please copy from the message... /* Header File for the Class /* #include "stdafx.h" #include "psapi.h" #pragma pack(16) #define FOUND_WJRU 0 #define WJRU_NOTFOUND 1 class CProcessMonitor { private: DWORD mAvailableProcesses[1024], cbNeeded, cProcesses; public: UINT getTotalAvailableProcesses(); UINT getProcessTimes(); BOOL FindProcessandMemoryDetails(DWORD processID,CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters); BOOL IsProcessMatchingNameAndID( DWORD processID, UINT index ); HANDLE GetProcessHandle(DWORD processID, CString Processname); HANDLE GetHandleToProcess(CString Processname); void GetJRUStatus(int&nStatus, PROCESS_MEMORY_COUNTERS& psMemInfo); }; #pragma pack() /// CPLUSS PLUS FILE.... #include "stdafx.h" #include "psapi.h" #include "EnumProcess.h" BOOL CProcessMonitor::IsProcessMatchingNameAndID( DWORD processID, UINT index ) { char szProcessName[MAX_PATH] = "unknown"; char szTargetProcessName[MAX_PATH] = "Wjru.exe"; PROCESS_MEMORY_COUNTERS psmemCounters; // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName) ); if(strcmp(szProcessName,szTargetProcessName) ==0) { GetProcessMemoryInfo(hProcess,&psmemCounters,sizeof(PROCESS_MEMORY_COUNTERS)); return TRUE; } else { return FALSE; } } } return FALSE; } BOOL CProcessMonitor::FindProcessandMemoryDetails(DWORD processID, CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters) { char szProcessName[MAX_PATH] = "unknown"; char szTargetProcessName[MAX_PATH]; strcpy(szTargetProcessName,Processname.GetBuffer(50)); Processname.ReleaseBuffer(); // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hPro

                K Offline
                K Offline
                kamalesh82
                wrote on last edited by
                #7

                Thanks for this nice and beutiful code. Thanks to all....All are helpfuls. Thanks again.

                kamalesh

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups