Safety of passing HBITMAP handle from unmanaged to managed code for created a System.Drawing.Bitmap
问题 I'm pretty new to managed/unmanaged interop, so I'm looking to get some opinions on how safe the following procedure is for getting a bitmap from unmanaged C++ to managed C#. The basic idea is: C# calls an interop function, FetchImage , which is in the unmanaged C++. It passes an out int param. FetchImage has a corresponding long * param. In C++, FetchImage creates a CBitmap somewhere safe, ie not local, draws something on it, uses HandleToLong() to convert the bitmap's HBITMAP handle to a