Jump to content
  • Advertisement
Sign in to follow this  
prophet tx-7

C++ RegGetValue - The sensless 234 error, when reading SZ after DWORD

This topic is 3052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a part of my code:
WCHAR szMultiSampleType[30];
if(RegGetValue(hKey, NULL, L"AntiAliasingON", RRF_RT_DWORD, NULL, (PVOID)&dwMultiSampleType, &dwDataSize) == ERROR_SUCCESS){
	if(dwMultiSampleType){	
		if((RegGetValue(hKey, NULL, L"D3DMULTISAMPLE_TYPE", RRF_RT_REG_SZ, NULL, (PVOID)szMultiSampleType, &dwDataSize))==ERROR_SUCCESS){
			if(!wcscmp(szMultiSampleType, L"D3DMULTISAMPLE_NONE")) dwMultiSampleType = 0;
			else if(!wcscmp(szMultiSampleType, L"D3DMULTISAMPLE_NONMASKABLE")) dwMultiSampleType = 1;
			else swscanf(szMultiSampleType, L"D3DMULTISAMPLE_%d_SAMPLES", &dwMultiSampleType);
			RegGetValue(hKey, NULL, L"MultiSampleQuality", RRF_RT_DWORD, NULL, (PVOID)&dwMultiSampleQuality, &dwDataSize);
		}
	}
}
When it tries to read the SZ, it returns 234 (more data availible). I dont understand this - the returned size is 56, so the buffer (szMultiSampleType) should handle it. I have also tried to increase its size, but with the same result. The strangest thing: When I move the getting of the SZ before DWORDs, it is OK, but I need to read some DWORDs before that. Any idea? THX

Share this post


Link to post
Share on other sites
Advertisement
I have figured it out. The last parameter (pcbData) is not just output parameter, its in/out and it has to be set to the size of the buffer in bytes.

So, because I have not initialized the dwDataSize, I was just (un)lucky - there was a big number and after reading DWORD it was set to 4, which was not enough for the SZ string. When SZ is read first, it sets dwDataSize to 54, which is enough for the DWORD.

Also, I have read, that RegGetValue is supported since Windows XP x64, so I have converted to RegQueryValueEx - but it requires the same last parameter - now solved :-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!