I want to save some floating point parameters in the registry and retrieve them in my program.
Question: How do I save floating point numbers in the registry? The values I want to save are in the range 0.2 to 5. For now, I multiply them by 1000 and save as REG_DWORD. After reading them, I divide again by 1000. Is this recommended?
ParamName is a TCHAR parameter that I send to the function, if it matches the key name then retrieve the value.
I have been able to get 0.2 into the string keydata.
Question: Both statements on Lines 16 and 17 put 0.0 in ParamVal even when the string value in keydata shows 0.2 in debug. Why does the parse of the string keydata to a floating point value not work?
and fvalue = atof(buffer); was taking 0.2 from buffer and converting to 0.0.
My best guess was that the string in buffer was not properly formatted and I decided to use the ANSI output function RegQueryValueExA, which seems to have worked. The contents of buffer were now displayed as
I switched off UNICODE character set (VS2008 > Project Properties > Configuration Properties > General, select "Character Set" and changed the "Use Unicode Character set" to "Use Multi-Byte Character Set".) and there were no problems using RegQueryValueEx.