Sorry...I misread your question.....
IF you want to cycle through the windows to find a specific window, then the best and most efficent option IMO is EnumWindows
Code:
#include <iostream>
#include <iomanip>
#include <cstring>
#include <windows.h>
using std::cout;
using std::endl;
using std::hex;
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
const int nSize = 100;
char szBuff[nSize] = {0};
char* str = (char*)lParam;
if(GetWindowText(hwnd,szBuff,nSize)){
if(!strcmp(str,szBuff)){
cout << hex;
cout << "Found the window called " << str;
cout << " on HWND number " << hwnd << endl;
return FALSE;
}
}
return TRUE;
}
int main(){
char *szWinName = "Calculator";
EnumWindows(EnumWindowsProc,(LPARAM)szWinName);
return 0;
}
This searches for the calculator program that comes with windows, but just change it as you wish for the window you need