在C++中,我们对一些窗口的操作,有时要获取到其窗口类,一下时获取到窗口类的方法。
#include <iostream> #include <Windows.h> // 或者windows.h using namespace std; int main() { HWND hwnd = GetForegroundWindow(); // 获取处于活动状态窗口句柄 char className[256]; GetClassName(hwnd, className, 256); // 窗口类名: className[] return 0; }
只能在 Windows 系统内使用!