逆向 | 查窗口名代码
存一份,有时候窗口名FindWindow找不到可能是少了空格之类的
#include <iostream>
#include <Windows.h>
using namespace std;
BOOL CALLBACK EnumChildProc( HWND hwnd, LPARAM lParam)
{
char szTitle[MAX_PATH] = {0};
char szClass[MAX_PATH] = {0};
int nMaxCount = MAX_PATH;
LPSTR lpClassName = szClass;
LPSTR lpWindowName = szTitle;
GetWindowTextA(hwnd, lpWindowName, nMaxCount);
GetClassNameA(hwnd, lpClassName, nMaxCount);
cout << "[Child window] window handle: " << hwnd << " window name: `"
<< lpWindowName << "` class name " << lpClassName << endl;
return TRUE;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
/*
* Remarks
The EnumWindows function does not enumerate child windows,
with the exception of a few top-level windows owned by the
system that have the WS_CHILD style.
*/
char szTitle[MAX_PATH] = {0};
char szClass[MAX_PATH] = {0};
int nMaxCount = MAX_PATH;
LPSTR lpClassName = szClass;
LPSTR lpWindowName = szTitle;
GetWindowTextA(hwnd, lpWindowName, nMaxCount);
GetClassNameA(hwnd, lpClassName, nMaxCount);
cout << "[Parent window] window handle: " << hwnd << " window name: `"
<< lpWindowName << "` class name " << lpClassName << endl;
//EnumChildWindows(hwnd, EnumChildProc, lParam);
return TRUE;
}
int main(int argc, char *argv[])
{
EnumWindows(EnumWindowsProc, 0);
system("pause");
return 0;
}
标签:逆向,窗口,MAX,代码,hwnd,nMaxCount,PATH
From: https://www.cnblogs.com/Mz1-rc/p/18287363