コード例 #1
0
        // Used by MCG's SafeHandle marshalling code to initialize a handle
        public static void InitializeHandle(SafeHandle safeHandle, IntPtr win32Handle)
        {
            // We need private reflection here to access the handle field.
            FieldInfo fieldInfo = safeHandle.GetType().GetField("handle", BindingFlags.NonPublic | BindingFlags.Instance);

            fieldInfo.SetValue(safeHandle, win32Handle);
        }