当前位置: 首页>>代码示例>>C++>>正文


C++ LPDATAOBJECT::GetData方法代码示例

本文整理汇总了C++中LPDATAOBJECT::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDATAOBJECT::GetData方法的具体用法?C++ LPDATAOBJECT::GetData怎么用?C++ LPDATAOBJECT::GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDATAOBJECT的用法示例。


在下文中一共展示了LPDATAOBJECT::GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UtGetIconData

FARINTERNAL UtGetIconData(LPDATAOBJECT lpSrcDataObj, REFCLSID rclsid,
		LPFORMATETC lpforetc, LPSTGMEDIUM lpstgmed)
{
	VDATEHEAP();

	CLSID clsid = rclsid;
	
	lpstgmed->tymed = TYMED_NULL;
	lpstgmed->pUnkForRelease = NULL;
	lpstgmed->hGlobal = NULL;
		
	if (lpSrcDataObj)
	{
	    if (lpSrcDataObj->GetData(lpforetc, lpstgmed) == NOERROR)
		    return NOERROR;
	    
	    if (IsEqualCLSID(clsid, CLSID_NULL))
		    UtGetClassID(lpSrcDataObj, &clsid);
	}
	
	// get data from registration database
	lpstgmed->hGlobal = OleGetIconOfClass(clsid, NULL, TRUE);
		
	if (lpstgmed->hGlobal == NULL)
	    return ResultFromScode(E_OUTOFMEMORY);
	else
	    lpstgmed->tymed = TYMED_MFPICT;

	return NOERROR;
}               
开发者ID:mingpen,项目名称:OpenNT,代码行数:30,代码来源:ole2util.cpp

示例2: OnDrop

HRESULT FTPWindow::OnDrop(LPDATAOBJECT pDataObj, DWORD /*grfKeyState*/, POINTL /*pt*/, LPDWORD pdwEffect) {
	TreeView_Select(m_treeview.GetHWND(), NULL, TVGN_DROPHILITE);

	STGMEDIUM medium;
	FORMATETC formatetc;
	formatetc.cfFormat = CF_HDROP;
	formatetc.tymed = TYMED_HGLOBAL;
	formatetc.dwAspect = 0;
	formatetc.lindex = -1;
	formatetc.ptd = NULL;;

	HRESULT dataRes = pDataObj->GetData(&formatetc, &medium);
	if (dataRes == S_OK) {
		*pdwEffect = DROPEFFECT_COPY;
		HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);

		TCHAR pathToFile[MAX_PATH];
		int filesDropped = DragQueryFile(hdrop, 0xffffffff, NULL, 0);
		for (int i = 0; i < filesDropped; ++i) {
			if (DragQueryFile(hdrop, i, pathToFile, MAX_PATH) != 0) {
				//pathToFile is not checked. If it doesnt exist or its a directory or link, CreateFile either allows a handle to be opened or not
				m_ftpSession->UploadFile(pathToFile, m_currentDropObject->GetPath(), true, 1);	//1: User specified location
			}
		}


		GlobalUnlock(medium.hGlobal);
		GlobalFree(medium.hGlobal);
	}

	return S_OK;
}
开发者ID:Praymundo,项目名称:NppFTP,代码行数:32,代码来源:FTPWindow.cpp

示例3: DragEnter

STDMETHODIMP CToolBarCombo::DragEnter(LPDATAOBJECT pDataObj , DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect){     
  m_pIDataObject=NULL;
  ATL::CString sText;

  FORMATETC formatDetails;     
  STGMEDIUM stmg;     

  // Let's get the text from the "clipboard"
  formatDetails.cfFormat = CF_TEXT;
  formatDetails.dwAspect = DVASPECT_CONTENT;
  formatDetails.lindex = -1;
  formatDetails.ptd = NULL;
  formatDetails.tymed = TYMED_HGLOBAL;

  if (SUCCEEDED(pDataObj->GetData(&formatDetails, &stmg)))
  {
    sText = (LPSTR)GlobalLock(stmg.hGlobal);
    GlobalUnlock(stmg.hGlobal);

    if (stmg.hGlobal != NULL) 
      ReleaseStgMedium(&stmg);             
  }

  *pdwEffect=DROPEFFECT_COPY;

  m_pIDataObject=pDataObj;     
  m_pIDataObject->AddRef();      

  return NOERROR;     
}       
开发者ID:henrywoo,项目名称:ultraie,代码行数:30,代码来源:ToolBarCombo.cpp

示例4: Drop

STDMETHODIMP CToolBarCombo::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect){     
  *pdwEffect=DROPEFFECT_NONE;      
  if (m_pIDataObject == NULL)         
    return E_FAIL;
  DragLeave();      

  FORMATETC formatDetails;     
  STGMEDIUM stmg;     

  // Let's get the text from the "clipboard"
  formatDetails.cfFormat = CF_TEXT;
  formatDetails.dwAspect = DVASPECT_CONTENT;
  formatDetails.lindex = -1;
  formatDetails.ptd = NULL;
  formatDetails.tymed = TYMED_HGLOBAL;

  if (SUCCEEDED(pDataObj->GetData(&formatDetails, &stmg)))
  {  
    char* sClipboard = (char*)GlobalLock(stmg.hGlobal);
    ::SetWindowTextA(m_hWnd,sClipboard);
    AddtoHistory(sClipboard);
    GlobalUnlock(stmg.hGlobal);
    if (stmg.hGlobal != NULL) 
      ReleaseStgMedium(&stmg);         
  }
  *pdwEffect=DROPEFFECT_COPY;
  //search immediately after dragging
  ::PostMessage(GetParent(),kWM_TBCOMBOSEARCH_WEB, 0, 0);
  return NOERROR;     
} 
开发者ID:henrywoo,项目名称:ultraie,代码行数:30,代码来源:ToolBarCombo.cpp

示例5: STDMETHOD

    STDMETHOD (DragEnter) (LPDATAOBJECT pDataObject, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
    {
        AddRef();
        m_filename[0] = 0;
        if (pDataObject)
        {
            FORMATETC fmte;
            fmte.cfFormat   = CF_HDROP;
            fmte.ptd        = NULL;
            fmte.dwAspect   = DVASPECT_CONTENT;  
            fmte.lindex     = -1;
            fmte.tymed      = TYMED_HGLOBAL;

            STGMEDIUM medium;
            if (SUCCEEDED(pDataObject->GetData(&fmte, &medium)))
            {
                HDROP hDrop = (HDROP)medium.hGlobal;
                m_filename[0] = 0;
                DragQueryFile(hDrop, 0, m_filename, sizeof(m_filename));
                DragFinish(hDrop);
                m_flags = is_stylefile(m_filename) ? 2 : 0;
            }
        }
        *pdwEffect = DROPEFFECT_NONE;
        return S_OK;
    }
开发者ID:Jmos,项目名称:bbclean-xzero450,代码行数:26,代码来源:Desk.cpp

示例6: Initialize

HRESULT CShellMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID)
{
	if(NULL == lpdobj)
	{
		return E_INVALIDARG;
	}

	FORMATETC feFmtEtc	= { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM mdmSTG	= { TYMED_HGLOBAL };
				
	if(FAILED(lpdobj->GetData(&feFmtEtc, &mdmSTG)))
	{
		return E_INVALIDARG;
	}

	HDROP hDrop = (HDROP)GlobalLock(mdmSTG.hGlobal);
    if(NULL == hDrop)
	{
        return E_INVALIDARG;
	}

	int nDropCount = ::DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
	
	if(nDropCount > 1)
		m_bMultiFile = true;
	else
		m_bMultiFile = false;

	if(nDropCount == 1)
	{
		::DragQueryFile(hDrop, 0, m_FileName, MAX_PATH);
	}

	return S_OK;
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:35,代码来源:ShellMenu.cpp

示例7: readFromDataObject

int readFromDataObject(LPDATAOBJECT lpDataObject, UINT fid, std::ostream& os, int* size, HWND hwnd)
{
	FORMATETC format;
	format.cfFormat = static_cast<CLIPFORMAT> (fid);
	format.dwAspect = DVASPECT_CONTENT;
	format.ptd = 0;
	format.tymed = TYMED_HGLOBAL;
	format.lindex = -1;

	STGMEDIUM medium;
	ZeroMemory (&medium, sizeof (medium));
	
	// Get the bitmap handle from the dropped IDataObject,
	// and then write it in the stream
	if (SUCCEEDED(lpDataObject->GetData(&format, &medium)))
    {
		if(medium.hGlobal != NULL)
		{
			os.write ((char *)&medium.hGlobal, sizeof(HANDLE));
			os << std::ends;
			*size = sizeof(HANDLE) + 1;
		}
    }
	return (medium.hGlobal != NULL);
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:25,代码来源:FIGLayer.cpp

示例8: Initialize

STDMETHODIMP CEsteidShlExt::Initialize (
	LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID )
{
	FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM stg = { TYMED_HGLOBAL };
	HDROP     hDrop;
	TCHAR szFile[MAX_PATH];
	HRESULT hr = S_OK;
	m_Files.clear();

	// Look for CF_HDROP data in the data object.
	if (FAILED(pDataObj->GetData(&fmt, &stg))) {
		// Nope! Return an "invalid argument" error back to Explorer.
		return E_INVALIDARG;
	}

	// Get a pointer to the actual data.
	hDrop = (HDROP) GlobalLock(stg.hGlobal);

	// Make sure it worked.
	if (hDrop == NULL) {
		ReleaseStgMedium(&stg);
		return E_INVALIDARG;
	}

	// Sanity check - make sure there is at least one filename.
	UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
	if (nFiles == 0) {
		GlobalUnlock(stg.hGlobal);
		ReleaseStgMedium(&stg);
		return E_INVALIDARG;
	}

	for (UINT i = 0; i < nFiles; i++) {
		// Get path length in chars
		UINT len = DragQueryFile(hDrop, i, NULL, 0);
		if (len == 0 || len >= MAX_PATH)
			continue;

		// Get the name of the file
		if (DragQueryFile(hDrop, i, szFile, len+1) == 0)
			continue;

		tstring str = tstring(szFile);
		if (str.empty())
			continue;

		m_Files.push_back(str);
	}

	if (m_Files.empty()) {
		// Don't show menu if no items were found
		hr = E_INVALIDARG;
	}

	GlobalUnlock(stg.hGlobal);
	ReleaseStgMedium(&stg);

	return hr;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:60,代码来源:EsteidShlExt.cpp

示例9: Initialize

STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY hRegKey)
{
	HRESULT hres = E_FAIL;
	STGMEDIUM medium;
	FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
	
	
	// Initialize can be called more than once
	if (m_pDataObj)
		m_pDataObj->Release();
	
	// duplicate the object pointer and registry handle
	if (pDataObj)
	{
		m_pDataObj = pDataObj;
		pDataObj->AddRef();
	}
	
	// use the given IDataObject to get a list of filenames (CF_HDROP)
	hres = pDataObj->GetData(&fmte, &medium);
	
	if(FAILED(hres))
		return E_FAIL;
	
	// find out how many files the user selected
	if(DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, NULL, 0) == 1)
		DragQueryFile((HDROP)medium.hGlobal, 0, m_szFile, sizeof(m_szFile));
	
	::ReleaseStgMedium(&medium);
	
	return NOERROR;
}
开发者ID:AtomLaw,项目名称:clamwin-0.1,代码行数:34,代码来源:ShellExtImpl.cpp

示例10: Initialize

STDMETHODIMP CShooterContextMenuExt::Initialize ( 
  LPCITEMIDLIST pidlFolder,
  LPDATAOBJECT pDataObj,
  HKEY hProgID )
{
	TCHAR     szFile[MAX_PATH];
	FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM stg = { TYMED_HGLOBAL };
	HDROP     hDrop;

	// Look for CF_HDROP data in the data object.
	if ( FAILED( pDataObj->GetData ( &fmt, &stg ) ))
	{
		// Nope! Return an "invalid argument" error back to Explorer.
		return E_INVALIDARG;
	}

	// Get a pointer to the actual data.
	hDrop = (HDROP) GlobalLock ( stg.hGlobal );

	// Make sure it worked.
	if ( NULL == hDrop )
	{
		ReleaseStgMedium ( &stg );
		return E_INVALIDARG;
	}

	// Sanity check - make sure there is at least one filename.
	UINT uNumFiles = DragQueryFile ( hDrop, 0xFFFFFFFF, NULL, 0 );
	HRESULT hr = S_OK;

	if ( 0 == uNumFiles )
	{
		GlobalUnlock ( stg.hGlobal );
		ReleaseStgMedium ( &stg );
		return E_INVALIDARG;
	}

	// Get the name of the first file and store it in our member variable m_szFile.
	m_bHasDir = false;

	for(UINT uFile = 0 ; uFile < uNumFiles ; uFile++)
	{
		if(0 == DragQueryFile(hDrop, uFile, szFile, MAX_PATH))
			continue;

		ATLTRACE("Checking file <%s>\n", szFile);

		m_fileList.push_back(szFile);

		if(IsDir(szFile))
			m_bHasDir = true;
	}


	GlobalUnlock ( stg.hGlobal );
	ReleaseStgMedium ( &stg );

	return hr;
}
开发者ID:4770K,项目名称:shooter-downloader,代码行数:60,代码来源:ShooterContextMenuExt.cpp

示例11: Initialize

HRESULT CSimpleShlExt::Initialize (LPCITEMIDLIST pidlFolder,
								   LPDATAOBJECT pDataObj,
								   HKEY hProgID )
{
	LPTSTR		lpszBuffer;
	FORMATETC	fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM	stg = { TYMED_HGLOBAL };
	HDROP		hDrop;
	UINT		uNumFiles,
				i;				

	// Look for CF_HDROP data in the data object.
	if (FAILED( pDataObj->GetData(&fmt, &stg) ))
		// Nope! Return an "invalid argument" error back to Explorer.
		return E_INVALIDARG;

	// Get a pointer to the actual data.
	hDrop = (HDROP) GlobalLock ( stg.hGlobal );

	// Make sure it worked.
	if (hDrop == NULL)
		return E_INVALIDARG;

	// Get the number of files selected
	// and make sure there is at least one file
	if ((uNumFiles = DragQueryFile( hDrop, 0xFFFFFFFF, NULL, 0 )) == 0)
	{
		GlobalUnlock( stg.hGlobal );
		ReleaseStgMedium( &stg );
		return E_INVALIDARG;
	}

	// Create buffer
	if (m_szFiles != NULL)
		delete [] m_szFiles;
	m_nFilesLength = 1;
	for (i=0; i<uNumFiles; ++i)
		m_nFilesLength += DragQueryFile(hDrop, i, NULL, 0) + 1;
	lpszBuffer = m_szFiles = new TCHAR[m_nFilesLength];
	if (m_szFiles == NULL)
	{
		GlobalUnlock( stg.hGlobal );
		ReleaseStgMedium( &stg );
		return E_INVALIDARG;
	}

	// Append all files into the buffer seperated by '\0'.
	for (i=0; i<uNumFiles; ++i)
	{
		lpszBuffer += DragQueryFile(hDrop, i, lpszBuffer, MAX_PATH);
		*lpszBuffer++ = _T('\0');
	}
	*lpszBuffer = _T('\0');	// End by a double '\0'.

	GlobalUnlock ( stg.hGlobal );
	ReleaseStgMedium ( &stg );

	return S_OK;
}
开发者ID:thecocce,项目名称:renameit,代码行数:59,代码来源:SimpleShlExt.cpp

示例12: Initialize

STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY hRegKey)
{
	if (pDataObj == 0)
	{
		return E_INVALIDARG;
	}
	HRESULT hr = E_FAIL;
	FORMATETC	format={CF_HDROP,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
	STGMEDIUM	medium;
	int			i;
	TCHAR		szDirectory[MAX_PATH];

	TCHAR szAppData[MAX_PATH];

	/*hr = */SHGetSpecialFolderPath(NULL, szAppData,CSIDL_COMMON_DESKTOPDIRECTORY ,FALSE);
    // Initialize can be called more than once
    if (m_pDataObj)
    	m_pDataObj->Release();
    // duplicate the object pointer and registry handle
    if (pDataObj)
    {
    	m_pDataObj = pDataObj;
    	pDataObj->AddRef();
    }
	GatherAppData();

	if (SUCCEEDED(pDataObj->GetData(&format,&medium)))
	{
		HDROP hDrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
		if (hDrop)
		{
			m_nSelected=DragQueryFile((HDROP&)medium.hGlobal,0xFFFFFFFF,NULL,0);
			for(i=0;i<m_nSelected;i++)
			{
				DragQueryFile((HDROP&)medium.hGlobal,i,szDirectory,MAX_PATH);
				if(i==0)
				{
					_tcscpy(m_szCommand,szDirectory);
					_tcscat(m_szCommand,_T("*"));
				}
				else
				{
					_tcscat(m_szCommand,szDirectory);
					_tcscat(m_szCommand,_T("*"));
				}
				hr = S_OK;
			}
			GlobalUnlock(medium.hGlobal);
		}

	}

    return hr;
}
开发者ID:xfxf123444,项目名称:japan,代码行数:56,代码来源:SHEXINIT.CPP

示例13: Initialize

//
//   FUNCTION: CDrmShlExt::Initialize(LPCITEMIDLIST, LPDATAOBJECT, 
//             HKEY)
//
//   PURPOSE: Initializes the context menu extension.
//
IFACEMETHODIMP CDrmShlExt::Initialize(
    LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID)
{
    HRESULT hr = E_INVALIDARG;
    
    if (NULL == pDataObj)
    {
        return hr;
    }

    FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
    STGMEDIUM stm;

    // pDataObj contains the objects being acted upon. In this project, 
    // we get an HDROP handle for enumerating the selected files.
    if (SUCCEEDED(pDataObj->GetData(&fe, &stm)))
    {
        // Get an HDROP handle.
        HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));
        if (hDrop != NULL)
        {
            // Determine how many files are involved in this operation.
            UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
            if (nFiles != 0)
            {
                // Get the name of the first file.
                if (0 != DragQueryFile(hDrop, 0, m_szFileName, MAX_PATH))
                {
                    hr = S_OK;
                }

                // [-or-]
				//store the list of filenames in our list				
				wchar_t tmpFile[MAX_PATH]; //temporary string to hold a file
				for(UINT i = 0; i < nFiles; i++)
				{
					if (0 == DragQueryFile(hDrop, i, tmpFile, MAX_PATH))
						hr = E_INVALIDARG;
					else
						this->fileList.push_front(tmpFile);
				}
                //hr = S_OK;
            }

            GlobalUnlock(stm.hGlobal);
        }

        ReleaseStgMedium(&stm);
    }

    // If any value other than S_OK is returned from the method, the context 
    // menu is not displayed.
    return hr;
}
开发者ID:Ochieng,项目名称:drm,代码行数:60,代码来源:DrmShlExt.cpp

示例14: Initialize

STDMETHODIMP CDeskBand::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY /* hRegKey */)
{
    m_ContextItems.clear();
    m_ContextDirectory.clear();
    // get selected files/folders
    if (pDataObj)
    {
        STGMEDIUM medium;
        FORMATETC fmte = {(CLIPFORMAT)g_shellidlist,
            (DVTARGETDEVICE FAR *)NULL,
            DVASPECT_CONTENT,
            -1,
            TYMED_HGLOBAL};
        HRESULT hres = pDataObj->GetData(&fmte, &medium);

        if (SUCCEEDED(hres) && medium.hGlobal)
        {
            //Enumerate PIDLs which the user has selected
            CIDA* cida = (CIDA*)GlobalLock(medium.hGlobal);
            ItemIDList parent( GetPIDLFolder (cida));

            int count = cida->cidl;
            for (int i = 0; i < count; ++i)
            {
                ItemIDList child (GetPIDLItem (cida, i), &parent);
                tstring str = child.toString();
                if (str.empty() == false)
                {
                    m_ContextItems[str] = ENABLED_VIEWPATH|ENABLED_FOLDERSELECTED|ENABLED_FILESELECTED;
                }
            }
            GlobalUnlock(medium.hGlobal);

            ReleaseStgMedium ( &medium );
            if (medium.pUnkForRelease)
            {
                IUnknown* relInterface = (IUnknown*)medium.pUnkForRelease;
                relInterface->Release();
            }
        }
    }

    // get folder background
    if (pIDFolder)
    {
        ItemIDList list(pIDFolder);
        m_ContextDirectory = list.toString();
    }

    return NOERROR;
}
开发者ID:SpivEgin,项目名称:stexbar,代码行数:53,代码来源:ContextMenu.cpp

示例15: Get

String UDropTarget::Get(const char *fmt) const
{
    FORMATETC fmtetc = ToFORMATETC(fmt);
    STGMEDIUM s;
    if(data->GetData(&fmtetc, &s) == S_OK && s.tymed == TYMED_HGLOBAL) {
        char *val = (char *)GlobalLock(s.hGlobal);
        String data(val, (int)GlobalSize(s.hGlobal));
        GlobalUnlock(s.hGlobal);
        ReleaseStgMedium(&s);
        return data;
    }
    return Null;
}
开发者ID:kolyden,项目名称:mirror,代码行数:13,代码来源:Win32DnD.cpp


注:本文中的LPDATAOBJECT::GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。