views:

33

answers:

1

In my VB.net Winforms application I'm using the ITaskbarList3::SetOverlayIcon interface to set status overlays on the application's taskbar button (under Windows 7). This all seems to work fine for me, with the icons being shown and removed correctly.

From the form load event, one of my functions makes the call

SetOverlayIcon(parentForm.Handle, IntPtr.Zero, String.Empty)

(where parentForm is the form which the load event has fired for) which very occasionally (on other people's machines) throws the following exception:

System.Runtime.InteropServices.COMException (0x8007057A): Invalid cursor handle. (Exception from HRESULT: 0x8007057A)
   at MyNamespace.TaskbarNotify.ITaskbarList3.SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, String pszDescription)

Out of a user base of a thousand or so users (of various Windows versions) this has been reported around 100 times over a couple of months.

I know that IntPtr.Zero isn't a valid cursor handle, but MSDN says that NULL is a valid value to pass for hIcon. Any suggestions as to what Windows is telling me?

Edit: I'm using .NET 2 in case this makes a difference.

A: 

You should use the Windows API Code Pack, which handles all of this for you.

SLaks
My application is GPL licensed, so I can't / would prefer not to include the Windows API Code Pack. Also, the code pack calls the same method with the same arguments that I'm passing, and doesn't add any extra exception handling, so I'd expect to see the same results.
ribbons