Desktop Functions: Smart Device Functions:
|
OleGetClipboard (ole32)
C# Signature:alternative
[DllImport("ole32.dll")] original
[DllImport("ole32.dll")] User-Defined Types:None. Notes:The original signature requires a definition for the COM version of IDataObject, as defined in objidl.h. The lack of this definition implies that the System.Windows.Forms.IDataObject interface can be used, but this interface, although COM-visible, is not the same as the COM one and results in a System.InvalidCastException. The alternative posted uses an object, which can then be passed to a System.Windows.Forms.DataObject ctor. Ideally though there should be a complete definition for the COM IDataObject interface (and all of its supporting types). Tips & Tricks:I find it better to turn off PreserveSig for methods that return an HRESULT and have a trailing out parameter, providing that the HRESULT does not have more that one success code (typically S_OK only). This results in a slightly cleaner syntax where the out parameter becomes the return value and a failing HRESULT results in an exception.
[DllImport("ole32.dll", PreserveSig=false)] C# Sample Code:
using System.Diagnostics; PreserveSig=true
class Program PreserveSig=false
class Program Alternative Managed API:System.Windows.Forms.Clipboard.GetDataObject Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|