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. Windows API
  4. how to get the primary thread ID from a spcified process ID?

how to get the primary thread ID from a spcified process ID?

Scheduled Pinned Locked Moved Windows API
tutorialquestion
6 Posts 3 Posters 20 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.
  • Y Offline
    Y Offline
    yph20040107
    wrote on last edited by
    #1

    Given a process ID, how to get its PRIMARY thread ID? THANK YOU!

    L S 3 Replies Last reply
    0
    • Y yph20040107

      Given a process ID, how to get its PRIMARY thread ID? THANK YOU!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      All can be found in the documentation[^].

      One of these days I'm going to think of a really clever signature.

      Y 1 Reply Last reply
      0
      • L Lost User

        All can be found in the documentation[^].

        One of these days I'm going to think of a really clever signature.

        Y Offline
        Y Offline
        yph20040107
        wrote on last edited by
        #3

        hi, thanks. The GetProcessInformation() only works on Windows Server 2012,my system is WinXP,how can i do?

        L 1 Reply Last reply
        0
        • Y yph20040107

          hi, thanks. The GetProcessInformation() only works on Windows Server 2012,my system is WinXP,how can i do?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry, I did not notice that. I guess you need to look at the related functions to see if any of them provide the information you are looking for.

          One of these days I'm going to think of a really clever signature.

          1 Reply Last reply
          0
          • Y yph20040107

            Given a process ID, how to get its PRIMARY thread ID? THANK YOU!

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Enumerate all threads, and select the oldest as described here[^].

            Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

            1 Reply Last reply
            0
            • Y yph20040107

              Given a process ID, how to get its PRIMARY thread ID? THANK YOU!

              S Offline
              S Offline
              skydger
              wrote on last edited by
              #6

              Hello! You can use a combination of CreateToolhelp32Snapshot, Thread32First and Thread32Next functions. Please see this example from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686852(v=vs.85).aspx[^]

              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