Implement a link source (or at least part of one)

S

Stephen Walch

I want to be able to drag objects from a third-party product to my .NET
Winforms app. If I look at the clipboard formats, there is nothing useful
except CF_LINKSOURCE, so I deduce that I need to do some OLE handshaking
(OleCreateLinkFromData, IPersistStorage, etc.). Does anyone have any
pointers as to how to do this from C# (.NET 1.1 preferred, .NET 2.0
acceptable). Thanks in advance!
 
M

Michael Phillips, Jr.

I wanted to pull image data out of a CF_LINKSOURCE.

Below is my approach using Platform Invoke:
1) Use OleGetClipboard to obtain a IOleDataObject interface.
2) Use OleGetData to obtain the IStream interface for the embedded link
data.
3) Use OleLoadFromStream to obtain the required IMoniker interface.
4) Create an IStorage interface to transfer the data
Use CreateILockBytesOnHGlobal and StgCreateDocfileOnILockBytes.
5) Use OleCreateLink to obtain the IDataObject for the data that is embedded
in the link.
6) Use OleRun to run OLE for the IDataObject
7) Pull the image data or Rtf and/or any other data that can be rendered
from the IDataObject.

Since IStorage is not represented in .Net 1.1, you must create an assembly
from a type library
for all the needed interfaces used by the OLE Platform Invoked functions.
 
T

TerryFei

Hi Stephen,

I just wanted to check how things are going and whether Michael's
suggestion is useful for you. If there is any question, please feel free to
join the community and we are here to support you at your convenience.
Thanks for your understanding!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top