I am using the Clipboard object to play with data copied to the clipboard. Lets say I have a few applications from which I can copy data to the clipboard like Excel, Notepad, etc.
I want to know whether there is any function or any way to find out from wh开发者_如何学Goere the data is captured in clipboard, whether it is coming from Excel or Notepad or from some unknown application.
I am using C# and .NET 2.0
If you are using SetClipboardViewer api to detect when something is copied to the clipboard and processing WM_DRAWCLIPBOARD message then you can use GetClipboardOwner function to find handle to the window which initiated the operation. Using the handle you can retrieve the process id and path of the executable.
Based on the Clipboard class reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx
You cannot tell exactly which application the content in the clipboard comes from.
You can make some sort of guess work though.
E.g. From the Clipboard.ContainsText Method (TextDataFormat)
, you can tell if it's an app that outputs/displays HTML, Text, RTF etc.
See http://msdn.microsoft.com/en-us/library/system.windows.forms.textdataformat.aspx
Other than that, I doubt you can go further.
精彩评论