I need to manipulate the StrVal
as the struct
is marshalled to managed C#. I am trying to use BSTR
string type, as it saves the memory allocation actions but I am not familiar with unmanaged data types. The problem is that I do not see any changes made to the value.
typedef struct {
int Id;
BSTR StrVal;
}packet;
packet pks [5];
// ...
pks[i].StrVal = L"abcdefghij";
for (int i = 0; i < 10; i++)
{
pks[i]=i;
//pks[i].StrVal = SysAllocString(L"abcdefghi"+i);
pks[i].StrVal[9]=i+'0';
}
How can I accomplish the task?