FOUND THE PROBLEM!
sizeof operator is the problem and causes a stack corruption.

Incorrect:
Code:
TCHAR szClassName[64];
GetClassName(hwnd, szClassName, sizeof(szClassName)-1);
szClassName[sizeof(szClassName)-1] = 0;
TCHAR uses two bytes of storage instead of one and this is the reason why I'm receiving bizarre crashes.

Correct:
This will work in both Unicode/Non-Unicode versions.
Code:
TCHAR szClassName[64];
GetClassName(hwnd, szClassName, sizeof(szClassName)/sizeof(TCHAR)-1);
szClassName[sizeof(szClassName)/sizeof(TCHAR)-1] = 0;
Here is an article that explains it all.

http://en.wiki.mcneel.com/default.as...dkCountOf.html