• Articles
  • Api Documentation
Show / Hide Table of Contents
  • Dapplo.Windows.App
    • AppQuery
  • Dapplo.Windows.Citrix
    • WinFrame
  • Dapplo.Windows.Citrix.Enums
    • ConnectStates
    • EventMask
    • InfoClasses
  • Dapplo.Windows.Citrix.Structs
    • ClientAddress
    • ClientDisplay
  • Dapplo.Windows.Clipboard
    • ClipboardMonitor
    • ClipboardNative
    • ClipboardUpdateInformation
    • StandardClipboardFormats
  • Dapplo.Windows.Com
    • ComProgIdAttribute
    • ComWrapper
    • DisposableCom
    • IDispatch
    • IDisposableCom<T>
    • IOleCommandTarget
    • IOleWindow
    • IUnknown
  • Dapplo.Windows.Common
    • Win32
    • WindowsVersion
  • Dapplo.Windows.Common.Enums
    • AdjacentTo
    • HResult
    • Win32Error
  • Dapplo.Windows.Common.Extensions
    • HResultExtensions
    • RectExensions
  • Dapplo.Windows.Common.Structs
    • POINT
    • RECT
    • RECTF
    • SIZE
  • Dapplo.Windows.Desktop
    • EnvironmentChangedEventArgs
    • EnvironmentMonitor
    • IInteropWindow
    • InteropWindow
    • InteropWindowExtensions
    • InteropWindowFactory
    • InteropWindowQuery
    • WindowScroller
    • WindowsEnumerator
    • WinEventHook
  • Dapplo.Windows.DesktopWindowsManager
    • Dwm
    • DwmBlurBehind
    • DwmBlurBehindFlags
    • DwmSetIconicLivePreviewFlags
    • DwmThumbnailProperties
    • DwmThumbnailPropertyFlags
    • DwmWindowAttributes
  • Dapplo.Windows.Dpi
    • BitmapScaleHandler
    • BitmapScaleHandler<TKey>
    • DpiAwareness
    • DpiAwarenessContext
    • DpiHandler
    • WinProcListener
  • Dapplo.Windows.Dpi.Enums
    • MonitorDpiType
  • Dapplo.Windows.Dpi.Forms
    • DpiAwareForm
    • FormsExtensions
  • Dapplo.Windows.Dpi.Wpf
    • WindowExtensions
  • Dapplo.Windows.Enums
    • InteropWindowCacheFlags
    • WinEventHookFlags
    • WinEvents
  • Dapplo.Windows.Gdi32
    • Gdi32Api
    • GdiExtensions
    • GdiPlusApi
  • Dapplo.Windows.Gdi32.Enums
    • BitmapCompressionMethods
    • ColorSpaceEnum
    • DeviceCaps
    • GdiPlusStatus
    • GpUnit
    • RasterOperations
  • Dapplo.Windows.Gdi32.SafeHandles
    • SafeCompatibleDcHandle
    • SafeDcHandle
    • SafeDeviceContextHandle
    • SafeDibSectionHandle
    • SafeHBitmapHandle
    • SafeObjectHandle
    • SafeRegionHandle
    • SafeSelectObjectHandle
    • SafeWindowDcHandle
  • Dapplo.Windows.Gdi32.Structs
    • BitfieldColorMask
    • BitmapFileHeader
    • BitmapInfoHeader
    • BlurParams
    • CieXyz
    • CieXyzTripple
  • Dapplo.Windows.Input
    • Hotkey
    • InputGenerator
    • KeyboardHook
    • KeyboardHookEventArgs
    • MouseHook
    • MouseHookEventArgs
  • Dapplo.Windows.Input.Enums
    • ExtendedKeyFlags
    • ExtendedMouseFlags
    • HookTypes
    • InputTypes
    • KeyEventFlags
    • MouseEventFlags
    • ScanCodes
    • VirtualKeyCodes
  • Dapplo.Windows.Input.Structs
    • HardwareInput
    • Input
    • InputUnion
    • KeyboardInput
    • KeyboardLowLevelHookStruct
    • MouseInput
    • MouseLowLevelHookStruct
  • Dapplo.Windows.Interop
    • DisposableCom
    • IDisposableCom<T>
  • Dapplo.Windows.Kernel32
    • Kernel32Api
    • PsApi
  • Dapplo.Windows.Kernel32.Enums
    • GlobalMemorySettings
    • ProcessAccessRights
    • ThreadAccess
    • WindowsProducts
    • WindowsProductTypes
    • WindowsSuites
  • Dapplo.Windows.Kernel32.Structs
    • OsVersionInfoEx
  • Dapplo.Windows.Messages
    • WindowsMessage
    • WindowsMessages
    • WinProcHandler
  • Dapplo.Windows.Multimedia
    • SoundSettings
    • SystemSounds
    • WinMm
  • Dapplo.Windows.Native
    • Shell32
    • Shell32.FolderType
    • Shell32.IconSize
  • Dapplo.Windows.Shell32
    • Shell32Api
  • Dapplo.Windows.Shell32.Enums
    • AppBarEdges
    • AppBarMessages
    • AppBarStates
  • Dapplo.Windows.Shell32.Structs
    • AppBarData
  • Dapplo.Windows.Structs
    • WinEventInfo
  • Dapplo.Windows.User32
    • User32Api
    • User32Api.EnumWindowsProc
  • Dapplo.Windows.User32.Enums
    • ClassLongIndex
    • CursorInfoFlags
    • DesktopAccessRight
    • ExtendedWindowStyleFlags
    • GetWindowCommands
    • MonitorFrom
    • MonitorInfoFlags
    • ObjectIdentifiers
    • ObjectStates
    • PrintWindowFlags
    • RegionResults
    • ScrollBarCommands
    • ScrollBarStateIndexes
    • ScrollBarTypes
    • ScrollInfoMask
    • ScrollModes
    • SendMessageTimeoutFlags
    • ShowWindowCommands
    • SysCommands
    • SystemMetric
    • SystemParametersInfoActions
    • SystemParametersInfoBehaviors
    • TitleBarInfoIndexes
    • WindowLongIndex
    • WindowPlacementFlags
    • WindowPos
    • WindowStyleFlags
  • Dapplo.Windows.User32.SafeHandles
    • SafeCurrentInputDesktopHandle
    • SafeIconHandle
  • Dapplo.Windows.User32.Structs
    • AnimationInfo
    • CursorInfo
    • DisplayInfo
    • IconInfo
    • MonitorInfoEx
    • ScrollBarInfo
    • ScrollInfo
    • TitleBarInfoEx
    • WindowInfo
    • WindowPlacement

Class ClipboardNative

Provides low level access to the Windows clipboard

Inheritance
System.Object
ClipboardNative
Namespace: Dapplo.Windows.Clipboard
Assembly: Dapplo.Windows.Clipboard.dll
Syntax
public static class ClipboardNative : object

Properties

| Improve this Doc View Source

CurrentOwner

Retrieves the current owner

Declaration
public static IntPtr CurrentOwner { get; }
Property Value
Type Description
IntPtr
| Improve this Doc View Source

SequenceNumber

Retrieves the current clipboard sequence number, either via GetClipboardSequenceNumber or internally

Declaration
public static uint SequenceNumber { get; }
Property Value
Type Description
System.UInt32

Methods

| Improve this Doc View Source

AvailableFormats()

Enumerate through all formats on the clipboard, assumes the clipboard was already locked.

Declaration
public static IEnumerable<string> AvailableFormats()
Returns
Type Description
IEnumerable<System.String>

IEnumerable with strings defining the format

| Improve this Doc View Source

Clear()

Empties the clipboard, this assumes that a lock has already been retrieved.

Declaration
public static void Clear()
| Improve this Doc View Source

GetAsStream(String)

Retrieve the content for the specified format. You will need to "lock" (OpenClipboard) the clipboard before calling this.

Declaration
public static MemoryStream GetAsStream(string format)
Parameters
Type Name Description
System.String format

the format to retrieve the content for

Returns
Type Description
MemoryStream

MemoryStream

| Improve this Doc View Source

GetAsUnicodeString(String)

Get a string from the clipboard, this assumes you already locked the clipboard. This always takes the CF_UNICODETEXT format, as Windows automatically converts

Declaration
public static string GetAsUnicodeString(string format = "CF_UNICODETEXT")
Parameters
Type Name Description
System.String format
Returns
Type Description
System.String

string

| Improve this Doc View Source

Lock(IntPtr, Int32, Nullable<TimeSpan>, Nullable<TimeSpan>)

Get a global lock to the clipboard

Declaration
public static IDisposable Lock(IntPtr hWnd = null, int retries = 5, TimeSpan? retryInterval = null, TimeSpan? timeout = null)
Parameters
Type Name Description
IntPtr hWnd

IntPtr with the windows handle

System.Int32 retries

int with the amount of lock attempts are made

System.Nullable<TimeSpan> retryInterval

Timespan between retries, default 200ms

System.Nullable<TimeSpan> timeout

Timeout for getting the lock

Returns
Type Description
IDisposable

IDisposable, which will unlock when Dispose is called

| Improve this Doc View Source

LockAsync(IntPtr, Int32, Nullable<TimeSpan>, CancellationToken)

Get a global lock to the clipboard

Declaration
public static Task<IDisposable> LockAsync(IntPtr hWnd = null, int retries = 5, TimeSpan? retryInterval = null, CancellationToken cancellationToken = null)
Parameters
Type Name Description
IntPtr hWnd

IntPtr with the windows handle

System.Int32 retries

int with the amount of lock attempts are made

System.Nullable<TimeSpan> retryInterval

Timespan between retries, default 200ms

CancellationToken cancellationToken

CancellationToken

Returns
Type Description
Task<IDisposable>

IDisposable in a Task, which will unlock when Dispose is called

| Improve this Doc View Source

RegisterFormat(String)

Register the clipboard format, so we can use it

Declaration
public static void RegisterFormat(string format)
Parameters
Type Name Description
System.String format

string with the format to register

| Improve this Doc View Source

SetAsBytes(Byte[], String)

Place byte[] on the clipboard, this assumes you already locked the clipboard.

Declaration
public static void SetAsBytes(byte[] bytes, string format)
Parameters
Type Name Description
System.Byte[] bytes

bytes to place on the clipboard

System.String format

format to place the bytes under

| Improve this Doc View Source

SetAsStream(String, MemoryStream)

Set the content for the specified format. You will need to "lock" (OpenClipboard) the clipboard before calling this.

Declaration
public static void SetAsStream(string format, MemoryStream stream)
Parameters
Type Name Description
System.String format

the format to set the content for

MemoryStream stream

MemoryStream with the content

| Improve this Doc View Source

SetAsUnicodeString(String, String)

Place string on the clipboard, this assumes you already locked the clipboard. It uses CF_UNICODETEXT by default, as all other formats are automatically generated from this by Windows.

Declaration
public static void SetAsUnicodeString(string text, string format = "CF_UNICODETEXT")
Parameters
Type Name Description
System.String text

string to place on the clipboard

System.String format
  • Improve this Doc
  • View Source
Back to top Copyright © 2017 Dapplo