问题
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:
Use EnumWindows to enumerate all top-level windows and get their handle.
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