use Marshal.FreeHGlobal
MODIFY
TextCopy/WindowsClipboard.cs
TextCopy/WindowsClipboard.cs
@@ -50,16 +50,13 @@ static class WindowsClipboard
{
if (hGlobal != IntPtr.Zero)
{
- GlobalFree(hGlobal);
+ Marshal.FreeHGlobal(hGlobal);
}
CloseClipboard();
}
}
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern IntPtr GlobalFree(IntPtr hMem);
-
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GlobalLock(IntPtr hMem);

use Marshal.FreeHGlobal