Is the application UNICODE? If so then there might be some problems with: RegQueryValueEx(tempKey,"Label", NULL, &dwType,(BYTE*) RegRead.GetBuffer(256), &dwSize); if this IS unicode then GetBuffer(256) will return 512 bytes (256 wchar_t) meaning your dwSize parameter is incorrect. Another possible problem would be if the RegQueryValueEx is appending a terminating NULL. Try calling RegRead.ReleaseBuffer(-1) instead.