From: mike1reynolds on
I am calling legacy Btrieve database functions using StructureToPtr and
PtrToStructure, but I think that I am getting memory corruption from improper
marshalling, and I am unclear about when memory is being copied vs memory
being pinned. Does StructureToPtr pin, or just copy?

I've seen references to pinning memory using GCHandles while googling the
topic, and I suspect that I might do better using GCHandle functions rather
than Marshal functions since these buffers are reused often. I've spent hours
on google trying to get a better understanding, but I'm still in a fog. Which
is the best approach for calling old C++ DLLs?