Buffer data size
-
Hi all. I have a doubt: how
ulSize
data buffer size should be:CString sValue; ULONG ulSize = \_MAX\_PATH; lRet = RegQueryValueEx(hKey, NULL, NULL, NULL, (BYTE\*)sValue.GetBuffer(\_MAX\_PATH), &ulSize); sValue.ReleaseBuffer();
or
CString sValue; ULONG ulSize = \_MAX\_PATH \* sizeof(TCHAR); lRet = RegQueryValueEx(hKey, NULL, NULL, NULL, (BYTE\*)sValue.GetBuffer(\_MAX\_PATH), &ulSize); sValue.ReleaseBuffer();
I guess that
ulSize
should be_MAX_PATH * sizeof(TCHAR);
like in the second code ... but I am not sure ... can you tell me how is right ? Thank you. -
Hi all. I have a doubt: how
ulSize
data buffer size should be:CString sValue; ULONG ulSize = \_MAX\_PATH; lRet = RegQueryValueEx(hKey, NULL, NULL, NULL, (BYTE\*)sValue.GetBuffer(\_MAX\_PATH), &ulSize); sValue.ReleaseBuffer();
or
CString sValue; ULONG ulSize = \_MAX\_PATH \* sizeof(TCHAR); lRet = RegQueryValueEx(hKey, NULL, NULL, NULL, (BYTE\*)sValue.GetBuffer(\_MAX\_PATH), &ulSize); sValue.ReleaseBuffer();
I guess that
ulSize
should be_MAX_PATH * sizeof(TCHAR);
like in the second code ... but I am not sure ... can you tell me how is right ? Thank you.From MSDN RegQueryValueEx function[^]:
Quote:
lpcbData [in, out, optional] A pointer to a variable that specifies the size of the buffer pointed to by the lpData parameter, in bytes.
So it must be the second version.
-
Hi all. I have a doubt: how
ulSize
data buffer size should be:CString sValue; ULONG ulSize = \_MAX\_PATH; lRet = RegQueryValueEx(hKey, NULL, NULL, NULL, (BYTE\*)sValue.GetBuffer(\_MAX\_PATH), &ulSize); sValue.ReleaseBuffer();
or
CString sValue; ULONG ulSize = \_MAX\_PATH \* sizeof(TCHAR); lRet = RegQueryValueEx(hKey, NULL, NULL, NULL, (BYTE\*)sValue.GetBuffer(\_MAX\_PATH), &ulSize); sValue.ReleaseBuffer();
I guess that
ulSize
should be_MAX_PATH * sizeof(TCHAR);
like in the second code ... but I am not sure ... can you tell me how is right ? Thank you. -
From MSDN RegQueryValueEx function[^]:
Quote:
lpcbData [in, out, optional] A pointer to a variable that specifies the size of the buffer pointed to by the lpData parameter, in bytes.
So it must be the second version.