Articles - Windows Clipboard Formats by Jochen Arndt | BESK.SU - программирование без границ (c) 2025

Articles Windows Clipboard Formats by Jochen Arndt

emailx45

Местный
Credits
513
Windows Clipboard Formats
Jochen Arndt - 07/Mar/2018
[SHOWTOGROUPS=4,20]
An overview of clipboard and Drag & Drop object formats.

Introduction
This reference gives you an overview of standard and common clipboard formats with links to the data structures.

Definitions

The following type definitions are used in the below tables:
  • ANSI textNull terminated ANSI or multi byte string.
  • Unicode textNull terminated Unicode (UTF-16LE) string.
  • ANSI / Unicode text listList of null terminated strings followed by a NULL character (double NULL terminated).
  • ASCII / ANSI textASCII 7-bit text by definition but ANSI 8-bit text may be supported.
  • DWORD (BOOL)DWORD value representing a boolean value (true if not zero).

Links indicate the destination in brackets. For MSDN links in the tables the indication is omitted.

Standard Clipboard Formats

The Standard Clipboard Formats [MSDN] use numeric IDs defined in WinUser.h. All non-standard formats must be registered using a unique format name.

Format IdentifierData TypeDescription
CF_TEXT (1)ANSI textText.
CF_BITMAP (2)HBITMAPHandle to a bitmap (GDI object).
CF_METAFILEPICT (3)METAFILEPICTWindows-Format Metafiles picture.
CF_SYLK (4)ANSI textMicrosoft Symbolic Link [Wikipedia].
CF_DIF (5)ASCII textSoftware Arts Data Interchange Format [Wikipedia].
CF_TIFF (6)TIFF [Wikipedia]TIFF image.
CF_OEMTEXT (7)8-Bit DOS textText.
CF_DIB (8)BITMAPINFOStructure followed by bitmap bits.
CF_PALETTE (9)HPALETTEHandle to a color palette (GDI object).
CF_PENDATA (10)-Windows 3.1 pen extension data.
CF_RIFF (11)RIFFResource Interchange File Format (RIFF) audio.
CF_WAVE (12)WAVEWAVE audio.
CF_UNICODETEXT (13)Unicode textText.
CF_ENHMETAFILE (14)HENHMETAFILEEnhanced-Format Metafiles handle.
CF_HDROP (15)DROPFILESList of file names.
CF_LOCALE (16)DWORD (LCID)LCID for CF_TEXT to CF_UNICODE conversion.
CF_DIBV5 (17)BITMAPV5HEADERStructure followed by bitmap bits
CF_DSPTEXT (0x0081)ANSI textText.
CF_DSPBITMAP (0x0082)HBITMAPHandle to a bitmap (GDI object)
CF_DSPMETAFILEPICT (0x0083)METAFILEPICTWindows-Format Metafiles picture.
CF_DSPENHMETAFILE (0x008E)HENHMETAFILEEnhanced-Format Metafiles handle.

Shell Clipboard Formats

The Shell Clipboard Formats [MSDN] are used to transfer shell objects via clipboard and Drag & Drop.

For most of them there is a definition for the format name in the header file shlobj.h:

DefinitionFormat Name
CFSTR_SHELLIDLISTShell IDList Array
CFSTR_SHELLIDLISTOFFSETShell Object Offsets
CFSTR_NETRESOURCESNet Resource
CFSTR_FILEDESCRIPTORAFileGroupDescriptor
CFSTR_FILEDESCRIPTORWFileGroupDescriptorW
CFSTR_FILECONTENTSFileContents
CFSTR_FILENAMEAFileName
CFSTR_FILENAMEWFileNameW
CFSTR_PRINTERGROUPPrinterFriendlyName
CFSTR_FILENAMEMAPAFileNameMap
CFSTR_FILENAMEMAPWFileNameMapW
CFSTR_SHELLURLUniformResourceLocator
CFSTR_INETURLAUniformResourceLocator
CFSTR_INETURLWUniformResourceLocatorW
CFSTR_PREFERREDDROPEFFECTPreferred DropEffect
CFSTR_PERFORMEDDROPEFFECTPerformed DropEffect
CFSTR_PASTESUCCEEDEDPaste Succeeded
CFSTR_INDRAGLOOPInShellDragLoop
CFSTR_DRAGCONTEXTDragContext
CFSTR_MOUNTEDVOLUMEMountedVolume
CFSTR_PERSISTEDDATAOBJECTPersistedDataObject
CFSTR_TARGETCLSIDTargetCLSID
CFSTR_LOGICALPERFORMEDDROPEFFECTLogical Performed DropEffect
CFSTR_AUTOPLAY_SHELLIDLISTSAutoplay Enumerated IDList Array
CFSTR_UNTRUSTEDDRAGDROPUntrustedDragDrop
CFSTR_FILE_ATTRIBUTES_ARRAYFile Attributes Array
CFSTR_INVOKECOMMAND_DROPPARAMInvokeCommand DropParam
CFSTR_SHELLDROPHANDLERDropHandlerCLSID
CFSTR_DROPDESCRIPTIONDropDescription


Format NameData TypeDescription
AsyncFlagDWORD (BOOL)Perform insert/paste operation in the background. Used by Explorer to avoid blocking the current instance.
FileContentsBinaryFile content.
FileGroupDescriptorFILEGROUPDESCRIPTORArray of FILEDESCRIPTORs.
FileGroupDescriptorWFILEGROUPDESCRIPTORArray of FILEDESCRIPTORs.
FileNameANSI textSingle file name in short (8.3) format.
FileNameWUnicode textSingle file name.
FileNameMapANSI text listList of file names when renaming.
FileNameMapWUnicode text listList of file names when renaming.
MountedVolumeUnicode textPath for mounted volume.
Shell IDList ArrayCIDAArray of PIDL (pointer to ITEMIDLIST) offsets.
Autoplay Enumerated IDList ArrayCIDAArray of PIDL (pointer to ITEMIDLIST) offsets.
Shell Object OffsetsPOINT[]Array of points.
File Attributes ArrayFILE_ATTRIBUTES_ARRAYArray of file attributes.
Net ResourceNRESARRAYArray of NETRESOURCE structures.
PrinterFriendlyNameDROPFILESList of printer names.
UniformResourceLocatorANSI textURL
UniformResourceLocatorWUnicode textURL


[/SHOWTOGROUPS]
 

emailx45

Местный
Credits
513
[SHOWTOGROUPS=4,20]
Drag & Drop Related Formats

These formats are used with Drag & Drop. Most of them are not documented.

Format NameData TypeDescription
ComputedImageDWORD?
DisableDragTextDWORD (BOOL)?
DragContextIStreamUsed internally by the Windows drag/drop helpers.
DragImageBitsSHDRAGIMAGEDrag image bitmap.
DragSourceHelperFlagsDWORDValue passed to IDragSourceHelper2::SetFlags.
DragWindowDWORD (HWND)The window handle of the drag image window.
DropDescriptionDROPDESCRIPTIONAero drag cursor type and text.
DropHandlerCLSIDCLSID GUIDCLSID GUID of the drop handler.
InShellDragLoopDWORD (BOOL)Nonzero when within a drag-and-drop loop.
InvokeCommand DropParamUnicode text?
IsComputingImageDWORD (BOOL)?
IsShowingLayeredDWORD (BOOL)Nonzero when a drop target shows the drag image.
IsShowingTextDWORD (BOOL)Nonzero when a drop target requests update of Aero cursor.
Logical Performed DropEffectDWORD (DROPEFFECT)Logically performed drop effect with optimized moves.
Paste SucceededDWORD (DROPEFFECT)Set by target when delete-on-paste operation succeeded.
Performed DropEffectDWORD (DROPEFFECT)Performed drop effect set by the target.
Preferred DropEffectDWORD (DROPEFFECT)Preferred drop effect set by source. Used also with clipboard.
TargetCLSIDCLSID GUIDCLSID GUID of the drop target.
UntrustedDragDropDWORDURL Action Flags.
UsingDefaultDragImageDWORD (BOOL)Nonzero when the drag image is a system default image.

OLE Formats

Format NameData TypeDescription
LinkANSI text listOLE 1.0 link.
NativeBinaryOLE 1.0 data.
ObjectLinkANSI text listOLE 1.0 link.
OwnerLinkANSI text listOLE 1.0 link.
Data ObjectBinaryOLE 2.0 data.
Embedded ObjectBinaryOLE 2.0 data.
Object DescriptorOBJECTDESCRIPTOROLE 2.0 User interface information.
Link Source DescriptorOBJECTDESCRIPTOROLE 2.0 User interface information.
Link SourceIMonikerOLE 2.0. Followed by document class ID.
HyperlinkIHlinkMethods to enable a hyperlink to navigate to its target.

Common Application Clipboard Formats

Many applications use the file extension or the MIME type [Wikipedia] as format name and pass data using the corresponding file format.

The format names are case-insensitive but is is common practice to use all lower case for MIME types, all upper case for file extensions and Pascal case (upper case for first letter of each word) for descriptive names.

Clipboard and drop target applications that should be able to receive such formats should register all commonly used format name variations.

The header file UrlMon.h contains some definitions for MIME types (see URL Moniker Clipboard Formats [MSDN]).

Common Text Formats

Format NameData TypeDescription
text/plainASCII / ANSI textSee also CF_TEXT.
HTML FormatUTF-8 textMicrosoft specific HTML clipboard format.
text/htmlTextHTML [W3C] file content. The encoding is defined by BOM and HTML headers.
HTML (Hyper Text Markup Language)TextSee text/html.
text/csvASCII / ANSI textComma-Separated Values (CSV) [IETF] file content.
CSVASCII / ANSI textSee text/csv.
text/richtextASCII / ANSI textWord 2007: Rich Text Format (RTF) Specification, version 1.9.1 [Microsoft]
Rich Text FormatASCII / ANSI textSee above.
Rich Text Format Without ObjectsASCII / ANSI textSee above.
RichEdit Text and ObjectsASCII / ANSI textSee above.
RTF As TextASCII / ANSI textSee above.
text/uri-listASCII textThe text/uri-list Internet Media Type [IETF].

Common Image Formats

Format NameData TypeDescription
image/bmpBITMAPFILEHEADERFile header followed by info header (see CF_DIB and CF_DIBV5) and bitmap data.
BMPBITMAPFILEHEADERSee image/bmp.
image/gifBinaryGIF [W3C] file content.
GIFBinarySee image/gif.
image/jpegBinaryJPEG [W3C] file content.
JPEGBinarySee image/jpeg.
JPGBinarySee image/jpeg.
image/pngBinaryPNG [W3C] file content.
PNGBinarySee image/png.
image/tiffBinaryTIFF [Wikipedia] file content. See also CF_TIFF.

Points of Interest
My article Drag & Drop Images and Drop Descriptions for MFC Applications contains a demo application that can be used to show the objects actually on the clipboard (clipboard viewer) and the drag objects when dropping on an info list.

References
History
  • 2016-04-08 Initial version.
  • 2016-04-14 Minor text changings, added links to GUID and URL moniker formats.
  • 2016-04-18 Splitted and re-arranged tables, added some OLE formats, added text/richtext, corrected enhanced meta file type.
  • 2016-06-21 Added formats text/uri-list, image/bmp, BMP; added link to W3C clipboard API
  • 2017-06-22 Added AsyncFlag format and that Preferred DropEffect also used with clipboard.
  • 2018-03-08 Fixed wrong FileContents description.

License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL).


[/SHOWTOGROUPS]
 
Последнее редактирование:
Сверху