FOUND THE PROBLEM!
sizeof operator is the problem and causes a stack corruption.
Incorrect:
TCHAR uses two bytes of storage instead of one and this is the reason why I'm receiving bizarre crashes.Code:TCHAR szClassName[64]; GetClassName(hwnd, szClassName, sizeof(szClassName)-1); szClassName[sizeof(szClassName)-1] = 0;
Correct:
This will work in both Unicode/Non-Unicode versions.
Here is an article that explains it all.Code:TCHAR szClassName[64]; GetClassName(hwnd, szClassName, sizeof(szClassName)/sizeof(TCHAR)-1); szClassName[sizeof(szClassName)/sizeof(TCHAR)-1] = 0;
http://en.wiki.mcneel.com/default.as...dkCountOf.html




Reply With Quote