c# 托管对象与InPtr互转
GCHandle thisHandle = GCHandle.Alloc(this);//this 是 MyClass类型 IntPtr thisptr = GCHandle.ToIntPtr(thisHandle); GCHandle thisHandle = GCHandle.FromIntPtr(thisptr ); MyClass thisObject = (MyClass)thisHandle.Target;
GCHandle thisHandle = GCHandle.Alloc(this);//this 是 MyClass类型 IntPtr thisptr = GCHandle.ToIntPtr(thisHandle); GCHandle thisHandle = GCHandle.FromIntPtr(thisptr ); MyClass thisObject = (MyClass)thisHandle.Target;