Help with SafeGDIHandle()

ogjogj Posts: 2
edited February 24, 2017 2:29PM in PInvoke.Net
Hello all,

I was looking at the example codes for the API calls to ImageList_DrawEx and ImageList_SetOverlay in comctl32.

The code examples make a reference to a SafeGDIHandle() class.

Does anyone know where I can find the code or an example for this class?



  • Here you are:
    using System;
    using System.Runtime.InteropServices;
    using System.Runtime.ConstrainedExecution;
    using System.Security.Permissions;
    using Microsoft.Win32.SafeHandles;
    [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]
    class SafeGDIHandle : SafeHandleZeroOrMinusOneIsInvalid
        internal SafeGDIHandle()
            : base(true)
        internal SafeGDIHandle(IntPtr existingHandle, bool ownsHandle)
            : base(ownsHandle)
        protected override bool ReleaseHandle()
            return NativeMethods.DeleteObject(handle);
Sign In or Register to comment.