initial commit
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SHARP
|
||||
{
|
||||
internal class Buffers
|
||||
{
|
||||
private const uint CF_UNICODETEXT = 13;
|
||||
|
||||
public static string GetBuffer()
|
||||
{
|
||||
if (!WinAPI.IsClipboardFormatAvailable(13U) || !WinAPI.OpenClipboard(IntPtr.Zero))
|
||||
return (string) null;
|
||||
string buffer = string.Empty;
|
||||
IntPtr clipboardData = WinAPI.GetClipboardData(13U);
|
||||
if (!clipboardData.Equals((object) IntPtr.Zero))
|
||||
{
|
||||
IntPtr num = WinAPI.GlobalLock(clipboardData);
|
||||
if (!num.Equals((object) IntPtr.Zero))
|
||||
{
|
||||
try
|
||||
{
|
||||
buffer = Marshal.PtrToStringUni(num);
|
||||
WinAPI.GlobalUnlock(num);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine((object) ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
WinAPI.CloseClipboard();
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user