private void CreateCursor(int width, int height, BitmapHandle dibSectionHandle) { BitmapHandle monoBitmapHandle = null; try { monoBitmapHandle = new BitmapHandle(CreateBitmap(width, height, 1, 1, IntPtr.Zero)); ICONINFO icon = new ICONINFO(); icon.IsIcon = false; icon.xHotspot = 0; icon.yHotspot = 0; icon.ColorBitmap = dibSectionHandle; icon.MaskBitmap = monoBitmapHandle; _iconHandle = CreateIconIndirect(ref icon); if (!_iconHandle.IsInvalid) { _ghostCursor = CursorInteropHelper.Create(_iconHandle); } } finally { // destroy the temporary mono bitmap now ... if (monoBitmapHandle != null) { monoBitmapHandle.Dispose(); } } }