本文整理匯總了C++中LPDATAOBJECT::AddRef方法的典型用法代碼示例。如果您正苦於以下問題:C++ LPDATAOBJECT::AddRef方法的具體用法?C++ LPDATAOBJECT::AddRef怎麽用?C++ LPDATAOBJECT::AddRef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LPDATAOBJECT
的用法示例。
在下文中一共展示了LPDATAOBJECT::AddRef方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: Initialize
/// \brief Called by the shell when initializing a context menu or property sheet extension.
/// \param pIDFolder Specifies the parent folder
/// \param pDataObj Spefifies the set of items selected in that folder.
/// \param hRegKey Specifies the type of the focused item in the selection.
/// \return NOERROR in all cases.
/// Note that at the time this function is called, we don't know
/// (or care) what type of shell extension is being initialized.
/// It could be a context menu or a property sheet.\n
/// Extra: Implements the IShellExtInit member function necessary to support
/// the context menu and property sheet portioins of this shell extension.
STDMETHODIMP CContextMenu::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey)
{
ODS("CContextMenu::Initialize()");
// 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();
STGMEDIUM medium;
FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
UINT uCount;
if(SUCCEEDED(m_pDataObj->GetData(&fe, &medium)))
{
// Get the file name from the CF_HDROP.
uCount = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, NULL, 0);
if(uCount)
DragQueryFile((HDROP)medium.hGlobal, 0, m_szFile, MAX_MATROSKA_PATH-2);
ReleaseStgMedium(&medium);
}
}
return NOERROR;
}
示例2: 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;
}
示例3: PreparePathsAndCommandLine
STDMETHODIMP
CShellExt::Initialize(
LPCITEMIDLIST pIDFolder,
LPDATAOBJECT pDataObj,
HKEY hRegKey)
{
DualErr derr;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Initialize can be called more than once.
if (mPDataObj)
mPDataObj->Release();
// Duplicate the object pointer and registry handle, and extract the path
// of the file or drive being operated on.
if (NULL!=(int)(pDataObj))
{
mPDataObj = pDataObj;
pDataObj->AddRef();
derr = PreparePathsAndCommandLine();
}
if (derr.IsntError())
return NOERROR;
else
return E_OUTOFMEMORY;
}
示例4: 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;
}
示例5: Initialize
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) {
HRESULT hres = 0;
if (m_pDataObj)
m_pDataObj->Release();
if (pDataObj) {
m_pDataObj = pDataObj;
pDataObj->AddRef();
}
return NOERROR;
}
示例6: GetIDataObject
LPDATAOBJECT COleDataObject::GetIDataObject(BOOL bAddRef)
{
EnsureClipboardObject();
LPDATAOBJECT lpDataObject = m_lpDataObject;
if (bAddRef && lpDataObject != NULL)
lpDataObject->AddRef();
return lpDataObject;
}
示例7: Initialize
// *** IShellExtInit methods ***
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST /*pIDFolder*/, LPDATAOBJECT pDataObj, HKEY /*hRegKey*/) {
if (m_pDataObj) {
m_pDataObj->Release();
m_pDataObj = NULL;
}
if (pDataObj) {
m_pDataObj = pDataObj;
pDataObj->AddRef();
}
return NOERROR;
}
示例8: Initialize
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
LPDATAOBJECT pDataObj,
HKEY hRegKey)
{
FORMATETC format={CF_HDROP,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
STGMEDIUM medium;
int i,nLen;
WCHAR szDirectory[MAX_PATH];
HRESULT hr;
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();
}
pDataObj->GetData(&format,&medium);
m_nSelected=DragQueryFileW((HDROP&)medium.hGlobal,0xFFFFFFFF,NULL,0);
if (m_nSelected == -1 || m_nSelected ==0)
{
wcscpy(m_szCommand,L"DeleteFileInRecycled");
return NOERROR;
}
m_szCommand[0] = L'\0';
for(i=0;i<m_nSelected;i++)
{
DragQueryFileW((HDROP&)medium.hGlobal,i,szDirectory,MAX_PATH);
if (i != 0)
wcscat(m_szCommand,L" ");
nLen = wcslen(m_szCommand);
m_szCommand[nLen] = L'"';
m_szCommand[nLen+1] = L'\0';
wcscat(m_szCommand,szDirectory);
nLen = wcslen(m_szCommand);
m_szCommand[nLen] = L'"';
m_szCommand[nLen+1] = L'\0';
}
return NOERROR;
}
示例9: Initialize
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST /* pIDFolder */,
LPDATAOBJECT pDataObj,
HKEY /* hRegKey */)
{
// 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();
}
return NOERROR;
}
示例10: DragEnter
STDMETHODIMP UDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
{
GuiLock __;
LLOG("DragEnter " << pt);
data = pDataObj;
data->AddRef();
fmt.Clear();
IEnumFORMATETC *fe;
if(!ctrl || pDataObj->EnumFormatEtc(DATADIR_GET, &fe) != NOERROR) {
*pdwEffect = DROPEFFECT_NONE;
return NOERROR;
}
FORMATETC fmtetc;
while(fe->Next(1, &fmtetc, 0) == S_OK) {
fmt.FindAdd(FromWin32CF(fmtetc.cfFormat));
if(fmtetc.ptd)
CoTaskMemFree(fmtetc.ptd);
}
fe->Release();
DnD(pt, false, pdwEffect, grfKeyState);
return NOERROR;
}
示例11: Initialize
//.........這裏部分代碼省略.........
DebugFormatMessage("Cannot add item %s",szPath);
else
m_aComputers.Add(alloccopy(szPath));
}
else
DebugMessage("StrRetToStr failed");
}
else
DebugMessage("GetDisplayNameOf failed");
}
delete[] (BYTE*)pItemIDList;
}
GlobalUnlock(med.hGlobal);
if (med.pUnkForRelease==NULL)
GlobalFree(med.hGlobal);
else
med.pUnkForRelease->Release();
psf->Release();
}
else
{
FormatEtc.cfFormat=CF_HDROP;
if (m_pDataObj->GetData(&FormatEtc,&med)==S_OK)
{
LPDROPFILES df=(LPDROPFILES)GlobalLock(med.hGlobal);
if (df->fWide)
{
LPWSTR lpPtr=(LPWSTR)((BYTE*)df+df->pFiles);
SIZE_T nLen;
while (nLen=wcslen(lpPtr))
{
DebugFormatMessage(L"HDROP contains file %s",(LPCSTR)(lpPtr));
if (IsDirectory(lpPtr))
{
WCHAR szTarget[MAX_PATH];
switch (GetNethoodTarget(lpPtr,szTarget,MAX_PATH))
{
case 1:
m_aComputers.Add(alloccopy(szTarget));
break;
case 2:
m_aDirectories.Add(alloccopy(szTarget));
break;
case 0:
m_aDirectories.Add(alloccopy(lpPtr,nLen));
break;
}
}
else
m_aFiles.Add(alloccopy(lpPtr,nLen));
lpPtr+=nLen+1;
}
}
else
{
LPSTR lpPtr=(LPSTR)df+df->pFiles;
SIZE_T nLen;
while (nLen=strlen(lpPtr))
{
LPWSTR lpFile=alloccopyAtoW(lpPtr,nLen);
if (IsDirectory(lpFile))
m_aDirectories.Add(lpFile);
else
m_aFiles.Add(lpFile);
lpPtr+=nLen+1;
}
}
GlobalUnlock(med.hGlobal);
if (med.pUnkForRelease==NULL)
GlobalFree(med.hGlobal);
else
med.pUnkForRelease->Release();
}
}
// 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();
}
return NOERROR;
}