If we format your code a bit better, we can see a few issues with it.
BOOL add_window(HWND hwnd) {
TCHAR String[300] = {0};
if (!hwnd) {
return TRUE;
}
if (!::IsWindowVisible(hwnd)) {
return TRUE;
}
LRESULT result = SendMessage(hwnd, WM_GETTEXT, ARRAYSIZE(String), (LPARAM)String);
if (result >= ARRAYSIZE(String)) {
MessageBox(NULL, TEXT("Too many characters were copied into the buffer"), TEXT("Buffer overflow"), MB_OK);
}
return TRUE;
child_data data;
for(int i = 0; i < sizeof(String) / 8; i++) {
data.caption.push_back(String[i]);
}
TCHAR buffer[30];
GetClassName(hwnd, buffer, ARRAYSIZE(buffer));
for(int i = 0; i < sizeof(buffer) / 4; i++) {
data.ClassName.push_back(buffer[i]);
}
RECT childwindow;
int checkmain = GetWindowRect(hwnd, &childwindow);
if (checkmain = 0) {
}
data.handle = hwnd;
stuff.push_back(data);
return TRUE;
}