I am having problems with this code:
ImageElement oElement = new UM0516.ImageElement();
IntPtr pElement = Marshal.AllocHGlobal(Marshal.SizeOf(new UM0516.ImageElement()));
Marshal.StructureToPtr(oElement, pElement, true);
FILES_GetImageElement(handle, el, out pElement);
This is where I got confused: I will go through the code, and after I call this last function (which should change some bits in memory pointed to by pElement), I see a change in oElement !? I thought that Marshal.StructureToPtr "copies" the data from the managed structure into memory. Similarly, are both places actually the same? The oElement managed structure and allocated memory pointed to by pElement?
source
share