How to find the class name & title of a program in c++?

瘦欲@ 提交于 2019-12-23 05:17:47

问题


The question is how to find the class name from running programs and title of those programs. I know there already exist some scanning tools like WinDowse or spy++ from visual studio, but what I am asking you is how to make programs like those in our own source code, what function to use, is there some open source program that can help? Code appreciated, link's also :)


回答1:


  1. Use EnumWindows to enumerate all top-level windows and get their handle.

  2. Pass the handle to GetWindowText and GetClassName to get the window title and window class respectively.

Example:

EnumWindows(EnumProc, 0);

...

BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam) {
  TCHAR title[256];
  TCHAR className[256];

  GetWindowText(hWnd, title, 256);
  MessageBox(NULL, title, NULL, MB_OK);

  GetClassName(hWnd, className, 256);
  MessageBox(NULL, className, NULL, MB_OK);

  return TRUE;
}


来源:https://stackoverflow.com/questions/4727135/how-to-find-the-class-name-title-of-a-program-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!