avleo20
2009-04-23 04:39:58 UTC
Hello All,
I am trying to convert a list of Strings in LPWSTR* array. I am using the
following way to convert it. But here the problem occurs in the returning
array items. It contains all the elements same in the array. I found the
problme is due to memset() which updates the memory address everytime same as
earlier. Please help me out----
for(DWORD i = 0; i < itemIds->Count; i++)
{
ATL::CComBSTR itemWChar;
itemWChar = ::GetAtlBstr(itemIds[i]);
WCHAR _itemWChar[_MAX_PATH];
memset(_itemWChar, 0, sizeof(_itemWChar) / sizeof(_itemWChar[0]));
memcpy(_itemWChar, static_cast<BSTR>(itemWChar), itemWChar.ByteLength());
items[i] = _itemWChar;
}
I am trying to convert a list of Strings in LPWSTR* array. I am using the
following way to convert it. But here the problem occurs in the returning
array items. It contains all the elements same in the array. I found the
problme is due to memset() which updates the memory address everytime same as
earlier. Please help me out----
for(DWORD i = 0; i < itemIds->Count; i++)
{
ATL::CComBSTR itemWChar;
itemWChar = ::GetAtlBstr(itemIds[i]);
WCHAR _itemWChar[_MAX_PATH];
memset(_itemWChar, 0, sizeof(_itemWChar) / sizeof(_itemWChar[0]));
memcpy(_itemWChar, static_cast<BSTR>(itemWChar), itemWChar.ByteLength());
items[i] = _itemWChar;
}