/// <summary> /// Sets up an advisory connection to the data object. /// </summary> /// <param name="dataObject">The data object on which to set the advisory connection.</param> /// <param name="sink">The advisory sink.</param> /// <param name="format">The format on which to callback on.</param> /// <param name="advf">Advisory flags. Can be 0.</param> /// <returns>The ID of the newly created advisory connection.</returns> public static int Advise(IDataObject dataObject, IAdviseSink sink, string format, ADVF advf) { // Internally, we'll listen for any TYMED FORMATETC formatETC; FillFormatETC(format, TYMED_ANY, out formatETC); int connection; int hr = dataObject.DAdvise(ref formatETC, advf, sink, out connection); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } return(connection); }