mirror of
https://github.com/greenshot/greenshot.git
synced 2025-01-09 15:23:03 -08:00
31 lines
827 B
C#
31 lines
827 B
C#
using System;
|
|
using System.Security;
|
|
using System.Security.Permissions;
|
|
using Microsoft.Win32.SafeHandles;
|
|
|
|
namespace GreenshotPlugin.UnmanagedHelpers
|
|
{
|
|
/// <summary>
|
|
/// A SafeHandle class implementation for the hIcon
|
|
/// </summary>
|
|
public class SafeIconHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
|
|
|
/// <summary>
|
|
/// Needed for marshalling return values
|
|
/// </summary>
|
|
[SecurityCritical]
|
|
public SafeIconHandle() : base(true)
|
|
{
|
|
}
|
|
|
|
|
|
public SafeIconHandle(IntPtr hIcon) : base(true) {
|
|
SetHandle(hIcon);
|
|
}
|
|
|
|
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
|
protected override bool ReleaseHandle() {
|
|
return User32.DestroyIcon(handle);
|
|
}
|
|
}
|
|
} |