How to use IDataObject? Specifically, I'm writing a Shell Extension Object, I want to add an item to the shortcut menu of all files. But my implementation of IShellInitExt::Initialize fails because I do something wrong with IDataObject:
IDataObject::GetData fails with E_INVALIDARG. (Thanks for the elaborate message MSCode:STDMETHODIMP copy_to_dest::Initialize(LPCITEMIDLIST p_folder, IDataObject *p_data, HKEY prog_id) { // 17 lines of code when 1 would suffice if the API wasn't so // uselessly complicated. *sigh* FORMATETC fetc; fetc.cfFormat = CF_TEXT; fetc.ptd = 0; fetc.dwAspect = DVASPECT_CONTENT; fetc.lindex = -1; fetc.tymed = TYMED_HGLOBAL; STGMEDIUM stgm; stgm.tymed = TYMED_HGLOBAL; stgm.pUnkForRelease = 0; HRESULT hr = p_data->GetData(&fetc, &stgm); if(FAILED(hr)) { return hr; } LPTSTR filename = reinterpret_cast<LPTSTR>(GlobalLock(stgm.hGlobal)); source = filename; GlobalUnlock(stgm.hGlobal); GlobalFree(stgm.hGlobal); p_data->Release(); return S_OK; })
Thx in advance.



LinkBack URL
About LinkBacks
)


