Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: Идентификатор процесса  (Прочитано 5824 раз)
0 Пользователей и 1 Гость смотрят эту тему.
cooler
Участник

ru
Offline Offline
Пол: Мужской

« : 09-11-2004 15:14 » 

Известен идентификатор процесса.
Можно ли по нему узнать идентификатор окна этого процесса?
Записан
MasterAlexei
Гость
« Ответ #1 : 10-11-2004 14:30 » 

Не у всякого процесса есть окно!!!
Ну и у всякого окна есть процесс.

В этом нарпавлении надо копать.
Все взято из Platform SDK:

HANDLE SnapSschot  = CreateToolhelp32Snapshot(
  TH32CS_SNAPTHREAD,
  ProcessID
);

Перечисляем все потоки процесса:


THREADENTRY32 te;
BOOL WINAPI Thread32First(
  SnapSschot,    
  &te
);

BOOL WINAPI Thread32Next(
  SnapSschot,    
  &te
);

и получаем следующие данные:

GUITHREADINFO gui
BOOL WINAPI GetGUIThreadInfo(
  te.th32ThreadID,
  &gui
);


typedef struct tagGUITHREADINFO {
    DWORD   cbSize;
    DWORD   flags;
    HWND    hwndActive;
    HWND    hwndFocus;
    HWND    hwndCapture;
    HWND    hwndMenuOwner;
    HWND    hwndMoveSize;
    HWND    hwndCaret;
    RECT    rcCaret;
} GUITHREADINFO, *LPGUITHREADINFO;

и в обратную сторону

GetWindowThreadProcessId
The GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window.

DWORD GetWindowThreadProcessId(
  HWND hWnd,             // handle to window
  LPDWORD lpdwProcessId  // address of variable for process identifier
);
Записан
MasterAlexei
Гость
« Ответ #2 : 10-11-2004 14:35 » new

The GUITHREADINFO structure contains information about a GUI thread.

typedef struct tagGUITHREADINFO {
    DWORD   cbSize;
    DWORD   flags;
    HWND    hwndActive;
    HWND    hwndFocus;
    HWND    hwndCapture;
    HWND    hwndMenuOwner;
    HWND    hwndMoveSize;
    HWND    hwndCaret;
    RECT    rcCaret;
} GUITHREADINFO, *LPGUITHREADINFO;


Members

cbSize - Specifies the size of this structure, in bytes. This member must be set.
flags - Specifies the thread state. This member can be one or more of the following values. Value Meaning

GUI_CARETBLINKING  Represents the caret's blink state. This bit is set if the caret is visible.  
GUI_INMENU  Represents the thread's menu state. This bit is set if the thread is in menu mode.  
GUI_INMOVESIZE  Represents the thread's move state. This bit is set if the thread is in a move or size loop.  
GUI_POPUPMENUMODE  Represents the thread's pop-up menu state. This bit is set if the thread has an active pop-up menu.  
GUI_SYSTEMMENUMODE  Represents the thread's system menu state. This bit is set if the thread is in a system menu mode.  


hwndActive -Handle to the active window within the thread.
hwndFocus - Handle to the window that has the keyboard focus.
hwndCapture - Handle to the window that has captured the mouse.
hwndMenuOwner - Handle to the window that owns any active menus.
hwndMoveSize - Handle to the window in a move or size loop.
hwndCaret - Handle to the window that is displaying the caret.
rcCaret - A RECT structure that describes the caret's bounding rectangle, in client coordinates, relative to the window specified by the hwndCaret member.
Записан
Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines