c#获取对象指针&从指针转为对象

GCHandle objHandle = GCHandle.Alloc(Globals.Instance.BlackBoard, GCHandleType.WeakTrackResurrection);
int address = GCHandle.ToIntPtr(objHandle).ToInt32();

Object obj = GCHandle.FromIntPtr(new IntPtr(address)).Target;

objHandle.Free();

还可以配合Marshal使用
Marshal

留待后查,同时方便他人
联系我:renhanlinbsl@163.com
原文地址:https://www.cnblogs.com/ives/p/14872476.html