get thread handle
5 отговора
155 прегледа
get thread handle
Вземам HWND на някакъв прозорец, който няма нищо общо с моята програма.
Въпросът ми е как мога да разбера handle на thread-а създал този прозорец.
Със GetWindowThreadProcessId вземам process identifier и thread identifier.
Със OpenProcess вземам handle на процеса.
Но това което ми трябва е handle на thread-а.
Ако някой знае, благодаря му за отговора.
Поздрави от Бургас.
Въпросът ми е как мога да разбера handle на thread-а създал този прозорец.
Със GetWindowThreadProcessId вземам process identifier и thread identifier.
Със OpenProcess вземам handle на процеса.
Но това което ми трябва е handle на thread-а.
Ако някой знае, благодаря му за отговора.
Поздрави от Бургас.
Re: get thread handle
Ako si na Win2000 ili Me(eeee :) ) mogesh directno da polzwash OpenThread. Za drugite triabwa da pogledna w help-a che sum pozabrawil. Ochakwaj wkulchwane otnowo :)
Re: get thread handle
MSDN-а който имам е по-старичък и затова OpenThread я няма в него.
След като ми каза я видях в on-line хелпа на MS, но така или иначе това ми трябва да работи и под 95/98.
Благодаря все пак.
Поздрави от Бургас.
След като ми каза я видях в on-line хелпа на MS, но така или иначе това ми трябва да работи и под 95/98.
Благодаря все пак.
Поздрави от Бургас.
Re: get thread handle
Informacia ot MSDN January 2001:
Windows 2000: If you have a thread identifier, you can get the thread handle by calling the OpenThread function. OpenThread enables you to specify the handle's access rights and whether it can be inherited.
Windows NT 4.0 and earlier, Windows 95/98: The Win32 API does not provide a way to get the thread handle from the thread identifier. If the handles were made available this way, the owning process could fail because another process unexpectedly performed an operation on one of its threads, such as suspending it, resuming it, adjusting its priority, or terminating it. Instead, you must request the handle from the thread creator or the thread itself.
A thread can use the GetCurrentThread function to retrieve a pseudo handle to its own thread object. This pseudo handle is valid only for the calling process; it cannot be inherited or duplicated for use by other processes. To get the real handle to the thread, given a pseudo handle, use the DuplicateHandle function.
Windows 2000: If you have a thread identifier, you can get the thread handle by calling the OpenThread function. OpenThread enables you to specify the handle's access rights and whether it can be inherited.
Windows NT 4.0 and earlier, Windows 95/98: The Win32 API does not provide a way to get the thread handle from the thread identifier. If the handles were made available this way, the owning process could fail because another process unexpectedly performed an operation on one of its threads, such as suspending it, resuming it, adjusting its priority, or terminating it. Instead, you must request the handle from the thread creator or the thread itself.
A thread can use the GetCurrentThread function to retrieve a pseudo handle to its own thread object. This pseudo handle is valid only for the calling process; it cannot be inherited or duplicated for use by other processes. To get the real handle to the thread, given a pseudo handle, use the DuplicateHandle function.
Re: get thread handle
Wig sega - i MSDN-a poniakoga ne e towa koeto izglegda. Moge da wzemesh handle na thread winagi samo che ne se sestam s Win9x da ima priako API za towa. Obache mogesh da polzwash Thread32Next (Thread32First) i da si naprawish "snimka" na sustoianieto na thread-owete w momenta. Posle kato iterirash po thread-infoto s Thread32Next moge da imash opisanie na dwojkite thread ID , thread Handle. Koftito e che ti ste si wurtish tzikala, ama ako ne go prawish tchesto niama da imash problemi. Sustoto moge da go prawish i s processite Process32Next i pr. Wig toolhelp functions.
Re: get thread handle
За съжаление това не става защото Thread32Next по никакъв начин не дава thread handle. Надявах се, че ще има някоя недукоментирана API функция която да свърши работа, но май се оказва че няма. Все пак благодаря.
Поздрави от Бургас.
Поздрави от Бургас.