如何找到课程名称& C ++中程序的标题? [英] How to find the class name & title of a program in c++?
问题描述
问题是如何从运行的程序和那些程序的标题中找到类名。我知道已经有一些扫描工具,例如 WinDowse
或 Visual Studio的 spy ++
,但我要问的是如何制作类似于我们自己源代码中的程序,要使用什么功能,有一些开源程序可以帮助您吗?代码赞赏,链接也:)
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 :)
推荐答案
-
使用
EnumWindows
枚举所有顶级窗口并获取它们的句柄。
Use
EnumWindows
to enumerate all top-level windows and get their handle.
将句柄传递给 GetWindowText
和 GetClassName
到分别获取窗口标题和窗口类。
Pass the handle to GetWindowText
and GetClassName
to get the window title and window class respectively.
示例:
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;
}
这篇关于如何找到课程名称& C ++中程序的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!