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. how can i check whether notepad.exe is running in taskmanager or not

how can i check whether notepad.exe is running in taskmanager or not

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 6 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.
  • T Offline
    T Offline
    trinadh_t
    wrote on last edited by
    #1

    Hi, I want to findout whether notepad.exe is running in taskmanager or not. if i create a process to open notepad.exe then i can find process id and close it, but i am not opening notepad.exe through process. pls help me, waiting 4 ur reply bye trinadh

    O 1 Reply Last reply
    0
    • T trinadh_t

      Hi, I want to findout whether notepad.exe is running in taskmanager or not. if i create a process to open notepad.exe then i can find process id and close it, but i am not opening notepad.exe through process. pls help me, waiting 4 ur reply bye trinadh

      O Offline
      O Offline
      Owner drawn
      wrote on last edited by
      #2

      Here is an example...

      #include <windows.h>
      #include <stdio.h>
      #include "psapi.h"

      void PrintProcessNameAndID( DWORD processID )
      {
      char szProcessName[MAX_PATH] = "unknown";

      // Get a handle to the process.
      
      HANDLE hProcess = OpenProcess( PROCESS\_QUERY\_INFORMATION |
                                     PROCESS\_VM\_READ,
                                     FALSE, processID );
      
      // Get the process name.
      
      if (NULL != hProcess )
      {
          HMODULE hMod;
          DWORD cbNeeded;
      
          if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), 
               &cbNeeded) )
          {
              GetModuleBaseName( hProcess, hMod, szProcessName, 
                                 sizeof(szProcessName) );
          }
          else return;
      }
      else return;
      
      // Print the process name and identifier.
      
      printf( "%s (Process ID: %u)\\n", szProcessName, processID );
      
      CloseHandle( hProcess );
      

      }

      void main( )
      {
      // Get the list of process identifiers.

      DWORD aProcesses\[1024\], cbNeeded, cProcesses;
      unsigned int i;
      
      if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
          return;
      
      // Calculate how many process identifiers were returned.
      
      cProcesses = cbNeeded / sizeof(DWORD);
      
      // Print the name and process identifier for each process.
      
      for ( i = 0; i < cProcesses; i++ )
          PrintProcessNameAndID( aProcesses\[i\] );
      

      }

      Love Forgives--Love Gives--Jesus is Love :)

      --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

      T 1 Reply Last reply
      0
      • O Owner drawn

        Here is an example...

        #include <windows.h>
        #include <stdio.h>
        #include "psapi.h"

        void PrintProcessNameAndID( DWORD processID )
        {
        char szProcessName[MAX_PATH] = "unknown";

        // Get a handle to the process.
        
        HANDLE hProcess = OpenProcess( PROCESS\_QUERY\_INFORMATION |
                                       PROCESS\_VM\_READ,
                                       FALSE, processID );
        
        // Get the process name.
        
        if (NULL != hProcess )
        {
            HMODULE hMod;
            DWORD cbNeeded;
        
            if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), 
                 &cbNeeded) )
            {
                GetModuleBaseName( hProcess, hMod, szProcessName, 
                                   sizeof(szProcessName) );
            }
            else return;
        }
        else return;
        
        // Print the process name and identifier.
        
        printf( "%s (Process ID: %u)\\n", szProcessName, processID );
        
        CloseHandle( hProcess );
        

        }

        void main( )
        {
        // Get the list of process identifiers.

        DWORD aProcesses\[1024\], cbNeeded, cProcesses;
        unsigned int i;
        
        if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
            return;
        
        // Calculate how many process identifiers were returned.
        
        cProcesses = cbNeeded / sizeof(DWORD);
        
        // Print the name and process identifier for each process.
        
        for ( i = 0; i < cProcesses; i++ )
            PrintProcessNameAndID( aProcesses\[i\] );
        

        }

        Love Forgives--Love Gives--Jesus is Love :)

        --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

        T Offline
        T Offline
        trinadh_t
        wrote on last edited by
        #3

        thanks for giving me reply, i try this code if i get any doubt i get back to u. bye trinadh

        O 1 Reply Last reply
        0
        • T trinadh_t

          thanks for giving me reply, i try this code if i get any doubt i get back to u. bye trinadh

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          Thanks to MSDN

          Love Forgives--Love Gives--Jesus is Love :)

          --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

          C 1 Reply Last reply
          0
          • O Owner drawn

            Thanks to MSDN

            Love Forgives--Love Gives--Jesus is Love :)

            --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

            C Offline
            C Offline
            color Aljechin
            wrote on last edited by
            #5

            :laugh:

            V 1 Reply Last reply
            0
            • C color Aljechin

              :laugh:

              V Offline
              V Offline
              vikas amin
              wrote on last edited by
              #6

              Error:Cannot open include file: 'psapi.h': Vikas Amin Embin Technology Bombay vikas.amin@embin.com

              D D 2 Replies Last reply
              0
              • V vikas amin

                Error:Cannot open include file: 'psapi.h': Vikas Amin Embin Technology Bombay vikas.amin@embin.com

                D Offline
                D Offline
                Dudi Avramov
                wrote on last edited by
                #7

                Try How to get handle to any running process by its name

                1 Reply Last reply
                0
                • V vikas amin

                  Error:Cannot open include file: 'psapi.h': Vikas Amin Embin Technology Bombay vikas.amin@embin.com

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  For header files other than my own, I use angle brackets <> instead of quotes. In any case, does the file exist on your machine?


                  "The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb

                  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