views:

43

answers:

2

Hi, I am using Clipboard object to play with data copied to clipboard. Lets say I have few application from which I can copy data to clipboard like excel,notepad,etc.

I want to know is there any function or is there any way to find out from where the data is captured in clipboard example is it coming from excel or notepad or from some unknown applucation.

I am using C# and .Net 2.0

+1  A: 

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.

o.k.w
A: 

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.

Giorgi