IDataObject::QueryGetData Method called by the shell to validate whether we can provide data in a specific format. In our case, we only supply text through an HGLOBAL. @param pformatetc Pointer to a FORMATETC struct describing the format. @return S_OK if we support the format, otherwise an error code.
| 232 | // @return S_OK if we support the format, otherwise an error code. |
| 233 | // |
| 234 | [[gsl::suppress(c.128), gsl::suppress(f.6)]] |
| 235 | STDMETHODIMP CPathCopyCopyDataHandler::QueryGetData( |
| 236 | FORMATETC *pformatetc) |
| 237 | { |
| 238 | HRESULT hRes = E_INVALIDARG; |
| 239 | if (pformatetc != nullptr) { |
| 240 | if (pformatetc->lindex != -1) { |
| 241 | hRes = DV_E_LINDEX; |
| 242 | } else if (pformatetc->dwAspect != DVASPECT_CONTENT) { |
| 243 | hRes = DV_E_DVASPECT; |
| 244 | } else if (pformatetc->cfFormat != CF_UNICODETEXT) { |
| 245 | hRes = DV_E_CLIPFORMAT; |
| 246 | } else if (pformatetc->tymed != TYMED_HGLOBAL) { |
| 247 | hRes = DV_E_TYMED; |
| 248 | } else { |
| 249 | // Caller is asking for text in the proper format, it will work. |
| 250 | hRes = S_OK; |
| 251 | } |
| 252 | } |
| 253 | return hRes; |
| 254 | } |
| 255 | |
| 256 | // |
| 257 | // IDataObject::GetCanonicalFormatEtc |