Original Post
I have written this simple test code: It's a Win32 Console Application with support for MFC. -------------------8<---------------------- #include "stdafx.h" #include int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { CRegKey regKey; regKey.Create(HKEY_CURRENT_USER, _T("SOFTWARE\\Test\\")); regKey.SetStringValue(_T("TestString1"), _T("2006-04-24")); TCHAR strValue[20]; ULONG numChars; regKey.QueryStringValue(_T("TestString1"), strValue, &numChars); _tprintf(_T("%s\n"), strValue); return 0; } -------------------8<---------------------- The String that is stored in registry and read back, "2006-04-24", is 11 chars long (with null), so 20 elements in strValue should be enough. But for some reason I get "Stack around variable 'strValue' was corrupted. I only get this problem with VS2003, but not with VS2005. I can solve the problem by using a variable on the heap with new, but I think this should work. Can you see a problem with my code causing this error? /Roq