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. Thread

Thread

Scheduled Pinned Locked Moved C / C++ / MFC
questionjson
7 Posts 3 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.
  • M Offline
    M Offline
    messages
    wrote on last edited by
    #1

    Hi everyone How can I find threads belong to a specific process? Is there any api for it?

    M 1 Reply Last reply
    0
    • M messages

      Hi everyone How can I find threads belong to a specific process? Is there any api for it?

      M Offline
      M Offline
      manoranjan
      wrote on last edited by
      #2

      You can use Tool Help API (i.e. Thread32First and Thread32Next). See a sample here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686852(v=vs.85).aspx[^]

      M 1 Reply Last reply
      0
      • M manoranjan

        You can use Tool Help API (i.e. Thread32First and Thread32Next). See a sample here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686852(v=vs.85).aspx[^]

        M Offline
        M Offline
        messages
        wrote on last edited by
        #3

        I have checked your link but I dont know why its result is different with Task manager Task manager shows 3 threads for calc.exe but this code generate these info Thread ID = 0x00016E0 base priority =8 delta priority =0 Thread ID= 0x0000558 base priority =8 delta priority =0 Thread ID= 0x0000115C base priority =15 delta priority =0 could you help me

        D 1 Reply Last reply
        0
        • M messages

          I have checked your link but I dont know why its result is different with Task manager Task manager shows 3 threads for calc.exe but this code generate these info Thread ID = 0x00016E0 base priority =8 delta priority =0 Thread ID= 0x0000558 base priority =8 delta priority =0 Thread ID= 0x0000115C base priority =15 delta priority =0 could you help me

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

          messages wrote:

          Task manager shows 3 threads for calc.exe...

          And your code's output shows the identifier of three threads. What were you expecting?

          messages wrote:

          ...but this code generate these info...

          The code uses GetCurrentProcessId(). How did you go about getting the process identifier for calc.exe?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          M 1 Reply Last reply
          0
          • D David Crow

            messages wrote:

            Task manager shows 3 threads for calc.exe...

            And your code's output shows the identifier of three threads. What were you expecting?

            messages wrote:

            ...but this code generate these info...

            The code uses GetCurrentProcessId(). How did you go about getting the process identifier for calc.exe?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            M Offline
            M Offline
            messages
            wrote on last edited by
            #5

            I used of Task manager for get PID

            D 1 Reply Last reply
            0
            • M messages

              I used of Task manager for get PID

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

              Ok, I ran that exact code, only changing:

              if (te32.th32OwnerProcessID == 4948) // process id of calc.exe

              and it produced:

              THREAD ID = 0x00000CB8
              base priority = 8
              delta priority = 0
              THREAD ID = 0x00000B18
              base priority = 8
              delta priority = 0
              THREAD ID = 0x000014B0
              base priority = 15
              delta priority = 0

              Given calc's three threads, that's what I would expect.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              M 1 Reply Last reply
              0
              • D David Crow

                Ok, I ran that exact code, only changing:

                if (te32.th32OwnerProcessID == 4948) // process id of calc.exe

                and it produced:

                THREAD ID = 0x00000CB8
                base priority = 8
                delta priority = 0
                THREAD ID = 0x00000B18
                base priority = 8
                delta priority = 0
                THREAD ID = 0x000014B0
                base priority = 15
                delta priority = 0

                Given calc's three threads, that's what I would expect.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                M Offline
                M Offline
                messages
                wrote on last edited by
                #7

                Got it rise and shine sleepyhead it has 3 "THREAD ID " so its 3 threads for calc.exe,is it correct?

                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