locked
How to share office word clipboard between windows 10 hosts by delayed rendering mechanism of the clipboard? RRS feed

  • Question

  • I am trying to imitate the implementation of rdpclip.exe to share clipboard data on one host with another host by the delayed rendering mechanism of the clipboard.

    My Solution: When the copy behavior occurs in host 1, a C# daemon process which calls AddClipboardFormatListener can capture and send the clipboard format list to a same daemon process on host 2, which will call SetClipboardData on host2 and set data to null. When the pasting behavior occurs on host 2, the data format information contained in the WM_RENDERFORMAT message is sent to the daemon on host 1, which is responsible for calling the GetClipboardData interface to obtain the business data, and reply to host 2, then the paste behavior on host 2 can be successfully completed.

    Everything works well until I use Word 2016. When I select all the content in the word window, including text and pictures, copy it, and paste it on another host, the text and text format can be pasted very well, but the pictures can not be displayed. I found that Word on host 1 stores some HTML format information in the clipboard. The pictures are actually placed under the temporary path list msohtmlclip and reflected in the clipboard in the form of links, so they cannot be transtered and pasted.

    But microsoft rdpclip.exe can do it. It does not simply paste the HTML format data. It seems to integrate all the content into the RTF format data segment and transter to another host. I don't know how to realize that, anyone know how to handle clipboard data sharing like Office Word? Thanks!

    Sunday, October 11, 2020 7:36 AM

Answers

  • Hi Acewind,

    Have you seen these two links? See if their solutions work for you.

    RDS Clipboard loosing HTML format when c drive redirected

    Text in clipboard loses formatting

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Acewind Wednesday, October 14, 2020 7:21 AM
    Wednesday, October 14, 2020 6:50 AM

All replies

  • Maybe you should check if more formats are available in Clipboard (see Clipboard.ContainText(…)) and take RTF even if HTML is also presented.

    Sunday, October 11, 2020 9:14 AM
  • I use EnumClipboardFormats to get all formats in source host and transfer the list to target host. Word 2016 running on target host sends serveral WM_RENDERFORMAT messages to my daemon process, but no RTF format is received.
    Monday, October 12, 2020 1:04 AM
  • The rich edit control registers its clipboard formats as discussed at https://docs.microsoft.com/en-us/windows/win32/controls/use-rich-edit-clipboard-operations#use-a-rich-edit-clipboard-operation

    The RTF formats will be numeric values in the range from 0xC000 to 0xFFFF and will not necessarily be the same on different systems.

    Call GetClipboardFormatName for the registered formats to identify the ones associated with RTF.

    For example, after pasting some RTF to the clipboard and enumerating the formats -

    Format is 49161, DataObject
    Format is 49281, Rich Text Format
    Format is 49289, Rich Text Format Without Objects
    Format is 49284, RTF As Text
    Format is CF_TEXT
    Format is CF_UNICODETEXT
    Format is 49285, RichEdit Binary
    Format is 49163, Embed Source
    Format is 49156, Native
    Format is 49155, OwnerLink
    Format is 49166, Object Descriptor
    Format is CF_METAFILEPICT
    Format is 49171, Ole Private Data
    Format is CF_LOCALE
    Format is CF_OEMTEXT
    Format is CF_ENHMETAFILE

    Monday, October 12, 2020 3:28 AM
  • When I select an area include text and pictures, then click copy button in Word 2016, rdpclip.exe sync clipboard from remote to localhost. Formats count on localhost  is less than remote host, some are deserted, some (such as Native) are added:

    clipboard viewer on remote host:

    clipboard viewer on remote host

    clipboard viewer on localhost:

    clipboard viewer on localhost

    My question is, how does rdpclip.exe know which formats must be deserted or added? Is there any standard or document?


    • Edited by Acewind Monday, October 12, 2020 5:22 AM
    Monday, October 12, 2020 4:09 AM
    • Edited by RLWA32 Monday, October 12, 2020 12:22 PM
    Monday, October 12, 2020 12:22 PM
  • I have read this document and wf_cliprdr.c code in freerdp, the wf_cliprdr.c does the same with my C# code: transfer all 18 formats in local clipboard to remote host, include HTML format. But in remote host clipboard, only 11 formats can be found. Some of them, such as HTML format, is not there. It seems that rdpclip.exe ignored those formats.

    I try use a whitelist to allow a part of formats to be transfered as rdpclip.exe, but it only suitable for Word, not for Powerpoint. 

    • Edited by Acewind Tuesday, October 13, 2020 8:56 AM
    Tuesday, October 13, 2020 8:13 AM
  • Hi Acewind,

    Have you seen these two links? See if their solutions work for you.

    RDS Clipboard loosing HTML format when c drive redirected

    Text in clipboard loses formatting

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Acewind Wednesday, October 14, 2020 7:21 AM
    Wednesday, October 14, 2020 6:50 AM
  • Thanks for your links! I think there's no exact rule to limit which formats can not be redirected, so I just filtered out HTML format, at least it works for Office softwares.
    Wednesday, October 14, 2020 7:23 AM