public static void SafeDestroyIcon(ref IntPtr hicon) { IntPtr p = hicon; hicon = IntPtr.Zero; if (IntPtr.Zero != p) { NativeMethodsShell.DestroyIcon(p); } }