Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionThreadmembermessages11 Dec '12 - 1:25 
Hi everyone
How can I find threads belong to a specific process?
Is there any api for it?
AnswerRe: Threadmembermanoranjan11 Dec '12 - 1:56 
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[^]
GeneralRe: Threadmembermessages11 Dec '12 - 2:10 
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
QuestionRe: Thread [modified]memberDavidCrow11 Dec '12 - 2:33 
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



modified 11 Dec '12 - 10:52.

AnswerRe: Threadmembermessages11 Dec '12 - 4:17 
I used of Task manager for get PID
GeneralRe: Thread [modified]memberDavidCrow11 Dec '12 - 4:55 
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



modified 11 Dec '12 - 13:02.

GeneralRe: Threadmembermessages11 Dec '12 - 5:25 
Got it rise and shine sleepyhead it has 3 "THREAD ID " so its 3 threads for calc.exe,is it correct?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid