How to get readable classname and title from HWND handle? in WinApi c++
I am using the following enumchild proc to get hwnd of each window, the problem is that i am unable to somehow detect any info from each hwnd so i can do what i want with the ones that are detected as the ones i need.
For example, how could i get window class name and the title of each window in the enum bellow?
I tried something like..
EDITED: copy pasted(if that helps)
TCHAR cName[MAX_PATH];
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) {
TCHAR cName[MAX_PATH];
GetClassName(hwnd, cName, _countof(cName));
cout << cName << endl;
retur开发者_C百科n TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
HWND hwnd = FindWindow(0, TEXT("reference"));
EnumChildWindows(hwnd, EnumChildProc, 0);
system("PAUSE");
return 0;
}
It just returns the hexadec handle info and every single time it is same, shouldnt the GetClassName func change the cName into new handle each time?
Also GetClassName function returns number of chars written to cName, i dont really see how this is useful to me? I need to get my cName in some readable format so i can do something like
if(className == TEXT("classnameiamlookingfor" && hwndtitle = TEXT("thetitlethatinterestsme") DOSOMETHINGWITHIT();
But all i get here is hexadec mess.
Isn't it Unicode build?
Check again with below:
TCHAR className[MAX_PATH];
GetClassName(hwnd, className, _countof(cName));
_tprintf(cName);
精彩评论