-->

How can I tell if Office Clipboard collection is t

2019-08-23 01:57发布

问题:

I want to know whether the Office clipboard collection is turned on. This is the clipboard pane that saves the last 24 clipboard data. On Office 2007 and 2010 you get it by expanding the clipboard area on the Home ribbon, and in Office 2003 you can open it from the task pane area, and selecting clipboard from the menu.

I've an Office plugin.

Although I'm doing all sort of API hooking (using IAT), I'm looking for the simplest solution.

  1. My initial idea was to look for a window with title: "Collect and Paste 2.0" (check out yourself with Spy++), with various Windows class (e.g. in Word it is bosa_sdm_msword). However, users can check the 'Collect without showing Office clipboard', and restart Office. At this point, Office will collect data without any sign to the Window.

  2. I am looking at registry key: Software\Microsoft\Office\%d.0\Common\General\AcbOn. This is cool, but this entry isn't saved until user exit Office. Hence, users can open a different application, turn on collection, close the window.

  3. Office clipboard creates an icon in the notification area. See question: how to acquire list of notification area icons?. Unfortunately, this question got no answer that work. If you know the answer for this, please reply here or on that question (you'll get +1 twice!)

As I said, I'm inside the process of the application and I'm able to intercept anything that has an export symbol, but I'd like to minimize the effect on the application. For example, intercepting send message, or subclassing a Window will have an effect on the performance (and in some cases: stability) of the Office application.

In Office 2003 there is a window with a class named ('ActiveClipboard'), but I can't find it on 2007 and 2010. On the other hand I see WM_USER+2304, which I don't know what it is.

Has anyone went through that path? Any hint?

回答1:

Answering my own question:

As far as I can tell, Office doesn't have any event or API in the object model to tell you whether Office is collecting the clipboard. However, the combination of these two methods is working for me:

  1. Enumerate all windows in the system, and search for a Window with the following attributes (class name/title respectively):

    Word 2010: "bosa_sdm_msword", "Collect and Paste 2.0" Word 2003: "bosa_sdm_Microsoft Office Word 11.0", "Collect and Paste 2.0" Word 2007: "bosa_sdm_Microsoft Office Word 12.0", "Collect and Paste 2.0" Excel (all): bosa_sdm_XL9", "Collect and Paste 2.0" PowerPoint (all): "bosa_sdm_Mso96", L"Collect and Paste 2.0"

    If such a window exists, this means Office is collecting clipboard data.

  2. Search registry key: HKCR\Software\Microsoft\Office\14.0\Common\General\AcbOn (REG_DWORD). A value of 1 well tell you Office is collecting data.