Hi all, coding C++ in VS.NET 2003,
I need to look for the title of a window up to a set length. My only problem with my code is that for some reason windowTitle gets initialized to a string that is much longer than 14. For example, the first time my code runs lets say "Mozilla Firefox" is the window text returned. For some reason windowTitle is initialized to "[bunch of garbage characters]Mozilla Firefox".
Then my copy works. So if my length were 5, windowTitle would then be "MozilMozilla Firefox"
I have no idea what's going on.
-------Here's my code------------------
GetWindowText(hWnd, buffer, 256);
// Window we are looking for will always have the same first 14 chars
_tcsnccpy(windowTitle, buffer, WINDOW_TITLE_LENGTH); // Copy the first 14 chars
if (! _tcscmp( windowTitle, _T("14 chars we are looking for")) )