Registry
-
I use this code to create a value in Registry: CString strValue; DWORD dwBytes ; LPBYTE lpData ; strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?"); dwBytes = strValue.GetLength()+1; lpData = (LPBYTE) strValue.GetBuffer(dwBytes); ::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes); But the value data in Registry is just : "1doandaithietladaidaihoncaidoa" Someone plz help me to explain & give me a solution :sigh:
-
I use this code to create a value in Registry: CString strValue; DWORD dwBytes ; LPBYTE lpData ; strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?"); dwBytes = strValue.GetLength()+1; lpData = (LPBYTE) strValue.GetBuffer(dwBytes); ::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes); But the value data in Registry is just : "1doandaithietladaidaihoncaidoa" Someone plz help me to explain & give me a solution :sigh:
Your building a UNICODE application hence each character is 2 bytes wide. The correct value for
dwBytes
is:dwBytes = (strValue.getLength()+1)*sizeof(TCHAR);
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
I use this code to create a value in Registry: CString strValue; DWORD dwBytes ; LPBYTE lpData ; strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?"); dwBytes = strValue.GetLength()+1; lpData = (LPBYTE) strValue.GetBuffer(dwBytes); ::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes); But the value data in Registry is just : "1doandaithietladaidaihoncaidoa" Someone plz help me to explain & give me a solution :sigh:
-
I use this code to create a value in Registry: CString strValue; DWORD dwBytes ; LPBYTE lpData ; strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?"); dwBytes = strValue.GetLength()+1; lpData = (LPBYTE) strValue.GetBuffer(dwBytes); ::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes); But the value data in Registry is just : "1doandaithietladaidaihoncaidoa" Someone plz help me to explain & give me a solution :sigh:
-
I use this code to create a value in Registry: CString strValue; DWORD dwBytes ; LPBYTE lpData ; strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?"); dwBytes = strValue.GetLength()+1; lpData = (LPBYTE) strValue.GetBuffer(dwBytes); ::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes); But the value data in Registry is just : "1doandaithietladaidaihoncaidoa" Someone plz help me to explain & give me a solution :sigh:
Why are you calling
GetBuffer()
? Unless you are also modifyingstrValue
, it is unnecessary and potentially dangerous."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Why are you calling
GetBuffer()
? Unless you are also modifyingstrValue
, it is unnecessary and potentially dangerous."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Good point. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke