[SHELL32]
authorDavid Quintana <gigaherz@gmail.com>
Wed, 20 Aug 2014 00:39:40 +0000 (00:39 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Wed, 20 Aug 2014 00:39:40 +0000 (00:39 +0000)
* Stop using the C defines LPSHELLFOLDER, LPSHELLVIEW and LPUNKNOWN, and use the respective C++ interfaces instead.
* Change one batch of COM interface pointers into CComPtr-based pointers, and remove associated Release calls (including at least one that was not supposed to be there at all).
* Remove a couple (repeated multiple times) pointless casts.

svn path=/branches/shell-experiments/; revision=63908

23 files changed:
dll/win32/shell32/CMenuDeskBar.cpp
dll/win32/shell32/brsfolder.cpp
dll/win32/shell32/defcontextmenu.cpp
dll/win32/shell32/desktop.cpp
dll/win32/shell32/folders.cpp
dll/win32/shell32/folders/admintools.cpp
dll/win32/shell32/folders/cpanel.cpp
dll/win32/shell32/folders/desktop.cpp
dll/win32/shell32/folders/fonts.cpp
dll/win32/shell32/folders/fs.cpp
dll/win32/shell32/folders/mycomp.cpp
dll/win32/shell32/folders/mydocuments.cpp
dll/win32/shell32/folders/netplaces.cpp
dll/win32/shell32/folders/printers.cpp
dll/win32/shell32/folders/recyclebin.cpp
dll/win32/shell32/pidl.cpp
dll/win32/shell32/shellitem.cpp
dll/win32/shell32/shelllink.cpp
dll/win32/shell32/shellole.cpp
dll/win32/shell32/shellord.cpp
dll/win32/shell32/shlexec.cpp
dll/win32/shell32/shlfolder.cpp
dll/win32/shell32/shlview.cpp

index 485553b..7407638 100644 (file)
@@ -116,7 +116,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::QueryService(
     return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnFocusChangeIS(THIS_ LPUNKNOWN lpUnknown, BOOL bFocus)
+HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnFocusChangeIS(THIS_ IUnknown * lpUnknown, BOOL bFocus)
 {
     return S_OK;
 }
index ace3308..a8fde0f 100644 (file)
@@ -46,7 +46,7 @@ typedef struct tagbrowse_info
 
 typedef struct tagTV_ITEMDATA
 {
-   LPSHELLFOLDER lpsfParent; /* IShellFolder of the parent */
+   IShellFolder* lpsfParent; /* IShellFolder of the parent */
    LPITEMIDLIST  lpi;        /* PIDL relative to parent */
    LPITEMIDLIST  lpifq;      /* Fully qualified PIDL */
    IEnumIDList*  pEnumIL;    /* Children iterator */
@@ -81,9 +81,9 @@ static const LAYOUT_INFO g_layout_info[] =
                         BIF_NEWDIALOGSTYLE | \
                         BIF_BROWSEINCLUDEFILES)
 
-static void FillTreeView(browse_info*, LPSHELLFOLDER,
+static void FillTreeView(browse_info*, IShellFolder*,
                LPITEMIDLIST, HTREEITEM, IEnumIDList*);
-static HTREEITEM InsertTreeViewItem( browse_info*, IShellFolder *,
+static HTREEITEM InsertTreeViewItem( browse_info*, IShellFolder*,
                LPCITEMIDLIST, LPCITEMIDLIST, IEnumIDList*, HTREEITEM);
 
 static const WCHAR szBrowseFolderInfo[] = L"__WINE_BRSFOLDERDLG_INFO";
@@ -206,10 +206,11 @@ static void InitializeTreeView( browse_info *info )
     ILRemoveLastID(pidlParent);
     pidlChild = ILClone(ILFindLastID(root));
 
-    if (_ILIsDesktop(pidlParent)) {
+    if (_ILIsDesktop(pidlParent))
+    {
         hr = SHGetDesktopFolder(&lpsfParent);
     } else {
-        IShellFolder *lpsfDesktop;
+        CComPtr<IShellFolder> lpsfDesktop;
         hr = SHGetDesktopFolder(&lpsfDesktop);
         if (FAILED(hr)) {
             WARN("SHGetDesktopFolder failed! hr = %08x\n", hr);
@@ -218,7 +219,6 @@ static void InitializeTreeView( browse_info *info )
             return;
         }
         hr = lpsfDesktop->BindToObject(pidlParent, 0, IID_PPV_ARG(IShellFolder, &lpsfParent));
-        lpsfDesktop->Release();
     }
 
     if (FAILED(hr)) {
@@ -310,7 +310,7 @@ static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM)
  *  Success: TRUE
  *  Failure: FALSE
  */
-static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
+static BOOL GetName(IShellFolder * lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
 {
     BOOL   bSuccess=TRUE;
     STRRET str;
@@ -714,8 +714,9 @@ static HRESULT BrsFolder_Rename(browse_info *info, HTREEITEM rename)
 static HRESULT BrsFolder_NewFolder(browse_info *info)
 {
     DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
-    IShellFolder *desktop, *cur;
-    ISFHelper *sfhelper;
+    CComPtr<IShellFolder> desktop;
+    CComPtr<IShellFolder> cur;
+    CComPtr<ISFHelper> sfhelper;
     WCHAR name[MAX_PATH];
     HTREEITEM parent, added;
     LPTV_ITEMDATA item_data;
@@ -734,7 +735,6 @@ static HRESULT BrsFolder_NewFolder(browse_info *info)
     if(FAILED(hr))
         return hr;
     hr = desktop->BindToObject(info->pidlRet, 0, IID_PPV_ARG(IShellFolder, &cur));
-    desktop->Release();
     if(FAILED(hr))
         return hr;
 
@@ -750,7 +750,6 @@ static HRESULT BrsFolder_NewFolder(browse_info *info)
     if(len<MAX_PATH)
         name[len++] = '\\';
     hr = sfhelper->GetUniqueName(&name[len], MAX_PATH-len);
-    sfhelper->Release();
     if(FAILED(hr))
         goto cleanup;
 
@@ -792,7 +791,6 @@ static HRESULT BrsFolder_NewFolder(browse_info *info)
         goto cleanup;
 
     added = InsertTreeViewItem(info, cur, new_item, item_data->lpifq, NULL, parent);
-    cur->Release();
     SHFree(new_item);
 
     SendMessageW(info->hwndTreeView, TVM_SORTCHILDREN, FALSE, (LPARAM)parent);
@@ -842,7 +840,7 @@ static BOOL BrsFolder_OnSetExpanded(browse_info *info, LPVOID selection,
 
     /* If 'selection' is a string, convert to a Shell ID List. */ 
     if (is_str) {
-        IShellFolder *psfDesktop;
+        CComPtr<IShellFolder> psfDesktop;
         HRESULT hr;
 
         hr = SHGetDesktopFolder(&psfDesktop);
@@ -851,7 +849,6 @@ static BOOL BrsFolder_OnSetExpanded(browse_info *info, LPVOID selection,
 
         hr = psfDesktop->ParseDisplayName(NULL, NULL, (LPOLESTR)selection,
                                           NULL, &pidlSelection, NULL);
-        psfDesktop->Release();
         if (FAILED(hr))
             goto done;
     }
index 990023e..418dcc3 100644 (file)
@@ -37,10 +37,10 @@ class CDefaultContextMenu :
     public IContextMenu2
 {
     private:
-        IShellFolder *m_psf;
+        CComPtr<IShellFolder> m_psf;
         UINT m_cidl;
         PCUITEMID_CHILD_ARRAY m_apidl;
-        IDataObject *m_pDataObj;
+        CComPtr<IDataObject> m_pDataObj;
         PIDLIST_ABSOLUTE m_pidlFolder;
         DWORD m_bGroupPolicyActive;
         PDynamicShellEntry m_pDynamicEntries; /* first dynamic shell extension entry */
@@ -135,16 +135,12 @@ CDefaultContextMenu::~CDefaultContextMenu()
 
     if (m_pidlFolder)
         CoTaskMemFree(m_pidlFolder);
-    if (m_pDataObj)
-        m_pDataObj->Release();
     _ILFreeaPidl(const_cast<PITEMID_CHILD *>(m_apidl), m_cidl);
-    if (m_psf)
-        m_psf->Release();
 }
 
 HRESULT WINAPI CDefaultContextMenu::Initialize(const DEFCONTEXTMENU *pdcm)
 {
-    IDataObject *pDataObj;
+    CComPtr<IDataObject> pDataObj;
 
     TRACE("cidl %u\n", pdcm->cidl);
 
@@ -153,7 +149,6 @@ HRESULT WINAPI CDefaultContextMenu::Initialize(const DEFCONTEXTMENU *pdcm)
     if (m_cidl && !m_apidl)
         return E_OUTOFMEMORY;
     m_psf = pdcm->psf;
-    m_psf->AddRef();
 
     if (SUCCEEDED(SHCreateDataObject(pdcm->pidlFolder, pdcm->cidl, pdcm->apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj))))
         m_pDataObj = pDataObj;
@@ -164,12 +159,11 @@ HRESULT WINAPI CDefaultContextMenu::Initialize(const DEFCONTEXTMENU *pdcm)
     }
     else
     {
-        IPersistFolder2 *pf = NULL;
+        CComPtr<IPersistFolder2> pf = NULL;
         if (SUCCEEDED(m_psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &pf))))
         {
             if (FAILED(pf->GetCurFolder(reinterpret_cast<LPITEMIDLIST*>(&m_pidlFolder))))
                 ERR("GetCurFolder failed\n");
-            pf->Release();
         }
         TRACE("pidlFolder %p\n", m_pidlFolder);
     }
@@ -307,7 +301,7 @@ BOOL
 HasClipboardData()
 {
     BOOL bRet = FALSE;
-    IDataObject *pDataObj;
+    CComPtr<IDataObject> pDataObj;
 
     if(SUCCEEDED(OleGetClipboard(&pDataObj)))
     {
@@ -323,8 +317,6 @@ HasClipboardData()
             bRet = TRUE;
             ReleaseStgMedium(&medium);
         }
-
-        pDataObj->Release();
     }
 
     return bRet;
@@ -369,7 +361,7 @@ CDefaultContextMenu::LoadDynamicContextMenuHandler(HKEY hKey, const CLSID *pclsi
     if (IsShellExtensionAlreadyLoaded(pclsid))
         return S_OK;
 
-    IContextMenu *pcm;
+    CComPtr<IContextMenu> pcm;
     hr = SHCoCreateInstance(NULL, pclsid, NULL, IID_PPV_ARG(IContextMenu, &pcm));
     if (hr != S_OK)
     {
@@ -377,28 +369,24 @@ CDefaultContextMenu::LoadDynamicContextMenuHandler(HKEY hKey, const CLSID *pclsi
         return hr;
     }
 
-    IShellExtInit *pExtInit;
+    CComPtr<IShellExtInit> pExtInit;
     hr = pcm->QueryInterface(IID_PPV_ARG(IShellExtInit, &pExtInit));
     if (hr != S_OK)
     {
         ERR("Failed to query for interface IID_IShellExtInit hr %x pclsid %s\n", hr, wine_dbgstr_guid(pclsid));
-        pcm->Release();
         return hr;
     }
 
     hr = pExtInit->Initialize(m_pidlFolder, m_pDataObj, hKey);
-    pExtInit->Release();
     if (hr != S_OK)
     {
         TRACE("Failed to initialize shell extension error %x pclsid %s\n", hr, wine_dbgstr_guid(pclsid));
-        pcm->Release();
         return hr;
     }
 
     PDynamicShellEntry pEntry = (DynamicShellEntry *)HeapAlloc(GetProcessHeap(), 0, sizeof(DynamicShellEntry));
     if (!pEntry)
     {
-        pcm->Release();
         return E_OUTOFMEMORY;
     }
 
@@ -945,7 +933,7 @@ NotifyShellViewWindow(LPCMINVOKECOMMANDINFO lpcmi, BOOL bRefresh)
     if (!lpSB)
         return E_FAIL;
 
-    LPSHELLVIEW lpSV = NULL;
+    IShellView * lpSV = NULL;
     if (FAILED(lpSB->QueryActiveShellView(&lpSV)))
         return E_FAIL;
 
@@ -1060,7 +1048,7 @@ CDefaultContextMenu::DoPaste(
         dwKey = MK_CONTROL|MK_SHIFT;
     }
 
-    IDropTarget *pdrop;
+    CComPtr<IDropTarget> pdrop;
     hr = psfTarget->QueryInterface(IID_PPV_ARG(IDropTarget, &pdrop));
     if (FAILED(hr))
     {
@@ -1086,8 +1074,8 @@ HRESULT
 CDefaultContextMenu::DoCreateLink(
     LPCMINVOKECOMMANDINFO lpcmi)
 {
-    LPDATAOBJECT pDataObj;
-    IDropTarget *pDT;
+    CComPtr<IDataObject> pDataObj;
+    CComPtr<IDropTarget> pDT;
     HRESULT hr;
     CComPtr<IPersistFolder2> ppf2 = NULL;
     LPITEMIDLIST pidl;
@@ -1143,13 +1131,11 @@ CDefaultContextMenu::DoCreateLink(
 HRESULT CDefaultContextMenu::DoDelete(LPCMINVOKECOMMANDINFO lpcmi) {
     TRACE("(%p) Deleting\n", this);
 
-    LPDATAOBJECT pDataObj;
+    CComPtr<IDataObject> pDataObj;
 
     if (SUCCEEDED(SHCreateDataObject(m_pidlFolder, m_cidl, m_apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj))))
     {
-        pDataObj->AddRef();
         SHCreateThread(DoDeleteThreadProc, pDataObj, NULL, NULL);
-        pDataObj->Release();
     }
     else
         return E_FAIL;
@@ -1162,7 +1148,7 @@ CDefaultContextMenu::DoCopyOrCut(
     LPCMINVOKECOMMANDINFO lpcmi,
     BOOL bCopy)
 {
-    LPDATAOBJECT pDataObj;
+    CComPtr<IDataObject> pDataObj;
     HRESULT hr;
 
     if (SUCCEEDED(SHCreateDataObject(m_pidlFolder, m_cidl, m_apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj))))
@@ -1181,7 +1167,6 @@ CDefaultContextMenu::DoCopyOrCut(
         }
 
         hr = OleSetClipboard(pDataObj);
-        pDataObj->Release();
         return hr;
     }
 
@@ -1193,7 +1178,7 @@ CDefaultContextMenu::DoCopyOrCut(
         return E_FAIL;
     }
 
-    LPSHELLVIEW lpSV;
+    CComPtr<IShellView> lpSV;
     hr = lpSB->QueryActiveShellView(&lpSV);
     if (FAILED(hr))
     {
@@ -1211,7 +1196,6 @@ CDefaultContextMenu::DoCopyOrCut(
     } else
         ERR("failed to get item object\n");
 
-    lpSV->Release();
     return hr;
 }
 
@@ -1236,7 +1220,7 @@ CDefaultContextMenu::DoRename(
             (void)TreeView_EditLabel(hwnd, hItem);
     }
 
-    LPSHELLVIEW lpSV;
+    CComPtr<IShellView> lpSV;
     HRESULT hr = lpSB->QueryActiveShellView(&lpSV);
     if (FAILED(hr))
     {
@@ -1244,9 +1228,8 @@ CDefaultContextMenu::DoRename(
         return hr;
     }
 
-    lpSV->SelectItem(m_apidl[0],
-                     SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT);
-    lpSV->Release();
+    SVSIF selFlags = SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT;
+    lpSV->SelectItem(m_apidl[0], selFlags);
     return S_OK;
 }
 
@@ -1259,13 +1242,12 @@ CDefaultContextMenu::DoProperties(
 
     if (!pidlParent)
     {
-        IPersistFolder2 *pf;
+        CComPtr<IPersistFolder2> pf;
 
         /* pidlFolder is optional */
         if (SUCCEEDED(m_psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &pf))))
         {
             pf->GetCurFolder((_ITEMIDLIST**)&pidlParent);
-            pf->Release();
         }
     }
 
index a4afb60..5e7b903 100644 (file)
@@ -45,7 +45,7 @@ private:
     HWND hWndDesktopListView;
     CComPtr<IShellDesktopTray>        ShellDesk;
     CComPtr<IShellView>                DesktopView;
-    IShellBrowser *DefaultShellBrowser;
+    CComPtr<IShellBrowser> DefaultShellBrowser;
     LPITEMIDLIST pidlDesktopDirectory;
     LPITEMIDLIST pidlDesktop;
 public:
@@ -159,7 +159,7 @@ HRESULT CDesktopBrowser::Initialize(HWND hWndx, IShellDesktopTray *ShellDeskx)
 
 static CDesktopBrowser *SHDESK_Create(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
 {
-    IShellDesktopTray        *ShellDesk;
+    CComPtr<IShellDesktopTray>       ShellDesk;
     CComObject<CDesktopBrowser>        *pThis;
     HRESULT                    hRet;
 
index 1e05702..aedae6c 100644 (file)
@@ -96,7 +96,6 @@ void InitIconOverlays(void)
     WCHAR szName[MAX_PATH];
     WCHAR szValue[100];
     CLSID clsid;
-    IShellIconOverlayIdentifier * Overlay;
 
     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
         return;
@@ -131,12 +130,13 @@ void InitIconOverlays(void)
             dwSize = sizeof(szValue) / sizeof(WCHAR);
             if (RegGetValueW(hKey, szName, NULL, RRF_RT_REG_SZ, NULL, szValue, &dwSize) == ERROR_SUCCESS)
             {
+                CComPtr<IShellIconOverlayIdentifier> Overlay;
 
                 CLSIDFromString(szValue, &clsid);
                 dwResult = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellIconOverlayIdentifier, &Overlay));
                 if (dwResult == S_OK)
                 {
-                    Handlers[NumIconOverlayHandlers] = Overlay;
+                    Handlers[NumIconOverlayHandlers] = Overlay.Detach();
                     NumIconOverlayHandlers++;
                 }
             }
@@ -200,7 +200,7 @@ GetIconOverlay(LPCITEMIDLIST pidl, WCHAR * wTemp, int* pIndex)
 IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl)
 {
     CComPtr<IDefaultExtractIconInit>    initIcon;
-    IExtractIconW *extractIcon;
+    CComPtr<IExtractIconW> extractIcon;
     GUID const * riid;
     int icon_idx;
     UINT flags;
@@ -418,7 +418,7 @@ IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl)
             initIcon->SetNormalIcon(wTemp, icon_idx);
     }
 
-    return extractIcon;
+    return extractIcon.Detach();
 }
 
 /**************************************************************************
@@ -426,8 +426,8 @@ IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl)
 */
 IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
 {
-    IExtractIconW *extractIconW;
-    IExtractIconA *extractIconA;
+    CComPtr<IExtractIconW> extractIconW;
+    CComPtr<IExtractIconA> extractIconA;
     HRESULT hr;
 
     extractIconW = IExtractIconW_Constructor(pidl);
@@ -435,8 +435,7 @@ IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
         return NULL;
 
     hr = extractIconW->QueryInterface(IID_PPV_ARG(IExtractIconA, &extractIconA));
-    extractIconW->Release();
     if (FAILED(hr))
         return NULL;
-    return extractIconA;
+    return extractIconA.Detach();
 }
index 198b57d..35cf97f 100644 (file)
@@ -316,14 +316,14 @@ HRESULT WINAPI CAdminToolsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCIT
     else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+        pObj = IExtractIconA_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
     else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+        pObj = IExtractIconW_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
index cf0c9cf..306786a 100644 (file)
@@ -547,12 +547,12 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
             hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj);
         } else if (IsEqualIID(riid, IID_IExtractIconA) && (cidl == 1)) {
             pidl = ILCombine(pidlRoot, apidl[0]);
-            pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
+            pObj = IExtractIconA_Constructor(pidl);
             SHFree(pidl);
             hr = S_OK;
         } else if (IsEqualIID(riid, IID_IExtractIconW) && (cidl == 1)) {
             pidl = ILCombine(pidlRoot, apidl[0]);
-            pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
+            pObj = IExtractIconW_Constructor(pidl);
             SHFree(pidl);
             hr = S_OK;
         } else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA))
index 756d844..6fb5c35 100644 (file)
@@ -637,14 +637,14 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
     else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+        pObj = IExtractIconA_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
     else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+        pObj = IExtractIconW_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
@@ -1476,7 +1476,7 @@ HRESULT WINAPI CDesktopFolder::Drop(IDataObject *pDataObject,
 
         if (SUCCEEDED(hr))
         {
-            IDropTarget *pDT;
+            CComPtr<IDropTarget> pDT;
             hr = this->BindToObject(pidl, NULL, IID_PPV_ARG(IDropTarget, &pDT));
             CoTaskMemFree(pidl);
             if (SUCCEEDED(hr))
@@ -1517,13 +1517,12 @@ HRESULT WINAPI CDesktopFolder::_GetDropTarget(LPCITEMIDLIST pidl, LPVOID *ppvOut
 
             if (SUCCEEDED(hr))
             {
-                IShellFolder *psf;
+                CComPtr<IShellFolder> psf;
                 hr = this->BindToObject(pidlNext, NULL, IID_PPV_ARG(IShellFolder, &psf));
                 CoTaskMemFree(pidlNext);
                 if (SUCCEEDED(hr))
                 {
                     hr = psf->GetUIObjectOf(NULL, 1, &pidl, IID_IDropTarget, NULL, ppvOut);
-                    psf->Release();
                     if (FAILED(hr))
                         ERR("FS GetUIObjectOf failed: %x\n", hr);
                 }
index 644659e..c337e42 100644 (file)
@@ -409,14 +409,14 @@ HRESULT WINAPI CFontsFolder::GetUIObjectOf(
     else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+        pObj = IExtractIconA_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
     else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+        pObj = IExtractIconW_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
index 1bd214a..9ffd0b9 100644 (file)
@@ -350,7 +350,7 @@ HRESULT WINAPI CFSFolder::CompareIDs(LPARAM lParam,
 HRESULT WINAPI CFSFolder::CreateViewObject(HWND hwndOwner,
         REFIID riid, LPVOID * ppvOut)
 {
-    LPSHELLVIEW pShellView;
+    CComPtr<IShellView> pShellView;
     HRESULT hr = E_INVALIDARG;
 
     TRACE ("(%p)->(hwnd=%p,%s,%p)\n", this, hwndOwner, shdebugstr_guid (&riid),
@@ -373,7 +373,6 @@ HRESULT WINAPI CFSFolder::CreateViewObject(HWND hwndOwner,
             if (pShellView)
             {
                 hr = pShellView->QueryInterface(riid, ppvOut);
-                pShellView->Release();
             }
         }
     }
@@ -494,14 +493,14 @@ HRESULT WINAPI CFSFolder::GetUIObjectOf(HWND hwndOwner,
         else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
         {
             pidl = ILCombine (pidlRoot, apidl[0]);
-            pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+            pObj = IExtractIconA_Constructor (pidl);
             SHFree (pidl);
             hr = S_OK;
         }
         else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
         {
             pidl = ILCombine (pidlRoot, apidl[0]);
-            pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+            pObj = IExtractIconW_Constructor (pidl);
             SHFree (pidl);
             hr = S_OK;
         }
@@ -862,7 +861,7 @@ HRESULT WINAPI CFSFolder::MapColumnToSCID (UINT column,
 
 HRESULT WINAPI CFSFolder::GetUniqueName(LPWSTR pwszName, UINT uLen)
 {
-    IEnumIDList *penum;
+    CComPtr<IEnumIDList> penum;
     HRESULT hr;
     WCHAR wszText[MAX_PATH];
     WCHAR wszNewFolder[25];
@@ -900,8 +899,6 @@ next:
                 goto next;
             }
         }
-
-        penum->Release();
     }
     return hr;
 }
@@ -1749,8 +1746,8 @@ HRESULT WINAPI CFSFolder::_DoDrop(IDataObject *pDataObject,
 DWORD WINAPI CFSFolder::_DoDropThreadProc(LPVOID lpParameter) {
     CoInitialize(NULL);
     _DoDropData *data = static_cast<_DoDropData*>(lpParameter);
-    IDataObject *pDataObject;
-    HRESULT hr = CoGetInterfaceAndReleaseStream (data->pStream, IID_IDataObject, (void**) &pDataObject);
+    CComPtr<IDataObject> pDataObject;
+    HRESULT hr = CoGetInterfaceAndReleaseStream (data->pStream, IID_PPV_ARG(IDataObject, &pDataObject));
 
     if (SUCCEEDED(hr))
     {
@@ -1760,7 +1757,6 @@ DWORD WINAPI CFSFolder::_DoDropThreadProc(LPVOID lpParameter) {
         {
             pAsyncOperation->EndOperation(hr, NULL, data->pdwEffect);
         }
-        pDataObject->Release();
     }
     //Release the CFSFolder and data object holds in the copying thread.
     data->This->Release();
@@ -1861,7 +1857,7 @@ HRESULT WINAPI CFSFolder::_LoadDynamicDropTargetHandler(const CLSID *pclsid, LPC
     TRACE("CFSFolder::_LoadDynamicDropTargetHandler entered\n");
     HRESULT hr;
 
-    IPersistFile *pp;
+    CComPtr<IPersistFile> pp;
     hr = SHCoCreateInstance(NULL, pclsid, NULL, IID_PPV_ARG(IPersistFile, &pp));
     if (hr != S_OK)
     {
@@ -1875,6 +1871,5 @@ HRESULT WINAPI CFSFolder::_LoadDynamicDropTargetHandler(const CLSID *pclsid, LPC
         ERR("Failed to query for interface IID_IShellExtInit hr %x pclsid %s\n", hr, wine_dbgstr_guid(pclsid));
         return hr;
     }
-    pp->Release();
     return hr;
 }
\ No newline at end of file
index d9515ca..4b93fef 100644 (file)
@@ -326,7 +326,7 @@ HRESULT WINAPI CDrivesFolder::CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPC
 */
 HRESULT WINAPI CDrivesFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
 {
-    LPSHELLVIEW pShellView;
+    CComPtr<IShellView> pShellView;
     HRESULT hr = E_INVALIDARG;
 
     TRACE("(%p)->(hwnd=%p,%s,%p)\n", this,
@@ -353,7 +353,6 @@ HRESULT WINAPI CDrivesFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVO
         if (pShellView)
         {
             hr = pShellView->QueryInterface(riid, ppvOut);
-            pShellView->Release();
         }
     }
     TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut);
@@ -449,14 +448,14 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner,
     else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+        pObj = IExtractIconA_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
     else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+        pObj = IExtractIconW_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
index b5e99b4..20b4642 100644 (file)
@@ -283,7 +283,7 @@ HRESULT WINAPI CMyDocsFolder::CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPC
  */
 HRESULT WINAPI CMyDocsFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
 {
-    LPSHELLVIEW pShellView;
+    CComPtr<IShellView> pShellView;
     HRESULT hr = E_INVALIDARG;
 
     TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
@@ -309,7 +309,6 @@ HRESULT WINAPI CMyDocsFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVO
         if (pShellView)
         {
             hr = pShellView->QueryInterface(riid, ppvOut);
-            pShellView->Release();
         }
     }
     TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut);
@@ -401,14 +400,14 @@ HRESULT WINAPI CMyDocsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMID
     else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+        pObj = IExtractIconA_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
     else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+        pObj = IExtractIconW_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
index 00b3c53..198dde0 100644 (file)
@@ -140,7 +140,7 @@ HRESULT WINAPI CNetFolder::CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITE
 */
 HRESULT WINAPI CNetFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
 {
-    LPSHELLVIEW pShellView;
+    CComPtr<IShellView> pShellView;
     HRESULT hr = E_INVALIDARG;
 
     TRACE("(%p)->(hwnd=%p,%s,%p)\n", this,
@@ -167,7 +167,6 @@ HRESULT WINAPI CNetFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID
         if (pShellView)
         {
             hr = pShellView->QueryInterface(riid, ppvOut);
-            pShellView->Release();
         }
     }
     TRACE("-- (%p)->(interface=%p)\n", this, ppvOut);
@@ -257,14 +256,14 @@ HRESULT WINAPI CNetFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIS
     else if (IsEqualIID(riid, IID_IExtractIconA) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
+        pObj = IExtractIconA_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
     else if (IsEqualIID(riid, IID_IExtractIconW) && (cidl == 1))
     {
         pidl = ILCombine (pidlRoot, apidl[0]);
-        pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
+        pObj = IExtractIconW_Constructor (pidl);
         SHFree (pidl);
         hr = S_OK;
     }
index f459fa0..10c17a5 100644 (file)
@@ -448,7 +448,7 @@ HRESULT WINAPI CPrinterFolder::CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LP
  */
 HRESULT WINAPI CPrinterFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
 {
-    LPSHELLVIEW pShellView;
+    CComPtr<IShellView> pShellView;
     HRESULT hr = E_INVALIDARG;
 
     TRACE("(%p)->(hwnd=%p,%s,%p)\n", this,
index de50bd1..94417f5 100644 (file)
@@ -560,7 +560,7 @@ HRESULT WINAPI CRecycleBin::CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCIT
 
 HRESULT WINAPI CRecycleBin::CreateViewObject(HWND hwndOwner, REFIID riid, void **ppv)
 {
-    LPSHELLVIEW pShellView;
+    CComPtr<IShellView> pShellView;
     HRESULT hr = E_NOINTERFACE;
 
     TRACE("(%p, %p, %s, %p)\n", this, hwndOwner, debugstr_guid(&riid), ppv);
@@ -584,7 +584,6 @@ HRESULT WINAPI CRecycleBin::CreateViewObject(HWND hwndOwner, REFIID riid, void *
         if (pShellView)
         {
             hr = pShellView->QueryInterface(riid, ppv);
-            pShellView->Release();
         }
     }
     else
@@ -855,7 +854,7 @@ HRESULT WINAPI CRecycleBin::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
 {
     HRESULT hr;
     LPSHELLBROWSER lpSB;
-    LPSHELLVIEW lpSV = NULL;
+    IShellView * lpSV = NULL;
 
     TRACE("%p %p verb %p\n", this, lpcmi, lpcmi->lpVerb);
 
index 7f877b9..837d694 100644 (file)
@@ -51,7 +51,7 @@ static LPWSTR _ILGetTextPointerW(LPCITEMIDLIST pidl);
  * RETURNS
  *  True if the display name could be retrieved successfully, False otherwise
  */
-static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
+static BOOL ILGetDisplayNameExA(IShellFolder * psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
 {
     BOOL ret = FALSE;
     WCHAR wPath[MAX_PATH];
@@ -68,10 +68,10 @@ static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR pat
     return ret;
 }
 
-BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
+BOOL WINAPI ILGetDisplayNameExW(IShellFolder * psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
 {
     CComPtr<IShellFolder>        psfParent;
-    LPSHELLFOLDER lsf = psf;
+    IShellFolder * lsf = psf;
     HRESULT ret = NO_ERROR;
     LPCITEMIDLIST pidllast;
     STRRET strret;
@@ -141,7 +141,7 @@ BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR pa
 /*************************************************************************
  * ILGetDisplayNameEx        [SHELL32.186]
  */
-BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type)
+BOOL WINAPI ILGetDisplayNameEx(IShellFolder * psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type)
 {
     TRACE_(shell)("%p %p %p %d\n", psf, pidl, path, type);
 
@@ -681,7 +681,7 @@ LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
  *
  * NOTES
  */
-HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal)
+HRESULT WINAPI SHGetRealIDL(IShellFolder * lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal)
 {
     CComPtr<IDataObject>        pDataObj;
     HRESULT hr;
@@ -1063,7 +1063,7 @@ EXTERN_C LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath)
  *  the pidl can be a simple one. since we can't get the path out of the pidl
  *  we have to take all data from the pidl
  */
-HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl,
+HRESULT WINAPI SHGetDataFromIDListA(IShellFolder * psf, LPCITEMIDLIST pidl,
                                     int nFormat, LPVOID dest, int len)
 {
     LPSTR filename, shortname;
@@ -1121,7 +1121,7 @@ HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl,
  * SHGetDataFromIDListW [SHELL32.248]
  *
  */
-HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl,
+HRESULT WINAPI SHGetDataFromIDListW(IShellFolder * psf, LPCITEMIDLIST pidl,
                                     int nFormat, LPVOID dest, int len)
 {
     LPSTR filename, shortname;
index 49ae0ca..d684870 100644 (file)
@@ -244,7 +244,7 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
     IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
 {
     HRESULT hr;
-    IShellItem *newShellItem;
+    CComPtr<IShellItem> newShellItem;
     LPITEMIDLIST new_pidl;
     CComPtr<IPersistIDList>            newPersistIDList;
 
@@ -308,6 +308,8 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
         return hr;
     }
     ILFree(new_pidl);
-    *ppsi = newShellItem;
+
+    *ppsi = newShellItem.Detach();
+
     return hr;
 }
index 5de77b2..0b2d3c0 100644 (file)
@@ -2173,7 +2173,7 @@ HRESULT WINAPI CShellLink::DragEnter(IDataObject *pDataObject,
 {
     TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
     LPCITEMIDLIST pidlLast;
-    IShellFolder *psf;
+    CComPtr<IShellFolder> psf;
 
     HRESULT hr = SHBindToParent(pPidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
 
@@ -2185,8 +2185,6 @@ HRESULT WINAPI CShellLink::DragEnter(IDataObject *pDataObject,
             hr = mDropTarget->DragEnter(pDataObject, dwKeyState, pt, pdwEffect);
         else 
             *pdwEffect = DROPEFFECT_NONE;
-
-        psf->Release();
     }
     else
         *pdwEffect = DROPEFFECT_NONE;
index 56e6562..884ab67 100644 (file)
@@ -68,7 +68,7 @@ DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
 HRESULT WINAPI SHCoCreateInstance(
     LPCWSTR aclsid,
     const CLSID *clsid,
-    LPUNKNOWN pUnkOuter,
+    IUnknown * pUnkOuter,
     REFIID refiid,
     LPVOID *ppv)
 {
@@ -314,7 +314,7 @@ public:
     HRESULT Initialize(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, const IID *riidInstx);
 
     // IClassFactory
-    virtual HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
+    virtual HRESULT WINAPI CreateInstance(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppvObject);
     virtual HRESULT WINAPI LockServer(BOOL fLock);
 
 BEGIN_COM_MAP(IDefClFImpl)
@@ -346,7 +346,7 @@ HRESULT IDefClFImpl::Initialize(LPFNCREATEINSTANCE lpfnCIx, PLONG pcRefDllx, con
 /******************************************************************************
  * IDefClF_fnCreateInstance
  */
-HRESULT WINAPI IDefClFImpl::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
+HRESULT WINAPI IDefClFImpl::CreateInstance(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppvObject)
 {
     TRACE("%p->(%p,%s,%p)\n", this, pUnkOuter, shdebugstr_guid(&riid), ppvObject);
 
index 4dc6b94..8c7b541 100644 (file)
@@ -484,13 +484,13 @@ HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
  */
 HRESULT WINAPI SHDoDragDrop(
     HWND hWnd,
-    LPDATAOBJECT lpDataObject,
+    IDataObject * lpDataObject,
     LPDROPSOURCE lpDropSource,
     DWORD dwOKEffect,
     LPDWORD pdwEffect)
 {
     FIXME("(%p %p %p 0x%08x %p):stub.\n",
-    hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
+        hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
     return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
 }
 
@@ -1015,7 +1015,7 @@ HRESULT WINAPI SHCreateShellFolderViewEx(
     LPCSFV psvcbi,    /* [in] shelltemplate struct */
     IShellView **ppv) /* [out] IShellView pointer */
 {
-    IShellView *psf;
+    CComPtr<IShellView> psf;
     HRESULT hRes;
 
     TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
@@ -1028,7 +1028,6 @@ HRESULT WINAPI SHCreateShellFolderViewEx(
         return hRes;
 
     hRes = psf->QueryInterface(IID_PPV_ARG(IShellView, ppv));
-    psf->Release();
 
     return hRes;
 }
@@ -1050,14 +1049,14 @@ EXTERN_C BOOL WINAPI SHRunControlPanel (LPCWSTR lpcszCmdLine, HWND hwndMsgParent
     return 0;
 }
 
-static LPUNKNOWN SHELL32_IExplorerInterface=0;
+static IUnknown * SHELL32_IExplorerInterface=0;
 /*************************************************************************
  * SHSetInstanceExplorer            [SHELL32.176]
  *
  * NOTES
  *  Sets the interface
  */
-VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
+VOID WINAPI SHSetInstanceExplorer (IUnknown * lpUnknown)
 {    TRACE("%p\n", lpUnknown);
     SHELL32_IExplorerInterface = lpUnknown;
 }
@@ -1897,7 +1896,7 @@ HRESULT WINAPI SHCreateStdEnumFmtEtc(
     const FORMATETC *lpFormats,
     LPENUMFORMATETC *ppenumFormatetc)
 {
-    IEnumFORMATETC *pef;
+    CComPtr<IEnumFORMATETC> pef;
     HRESULT hRes;
     TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
 
@@ -1907,7 +1906,6 @@ HRESULT WINAPI SHCreateStdEnumFmtEtc(
 
     pef->AddRef();
     hRes = pef->QueryInterface(IID_PPV_ARG(IEnumFORMATETC, ppenumFormatetc));
-    pef->Release();
 
     return hRes;
 }
@@ -1918,7 +1916,7 @@ HRESULT WINAPI SHCreateStdEnumFmtEtc(
  */
 HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv)
 {
-    IShellView *psf;
+    CComPtr<IShellView> psf;
     HRESULT hRes;
 
     *ppsv = NULL;
@@ -1933,7 +1931,6 @@ HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **pps
         return hRes;
 
     hRes = psf->QueryInterface(IID_PPV_ARG(IShellView, ppsv));
-    psf->Release();
 
     return hRes;
 }
index e1e62cb..555c098 100644 (file)
@@ -404,7 +404,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
 static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
 {
     STRRET strret;
-    IShellFolder *desktop;
+    CComPtr<IShellFolder> desktop;
 
     HRESULT hr = SHGetDesktopFolder(&desktop);
 
@@ -414,8 +414,6 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz
 
         if (SUCCEEDED(hr))
             StrRetToStrNW(pszPath, uOutSize, &strret, pidl);
-
-        desktop->Release();
     }
 
     return hr;
@@ -1782,7 +1780,7 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
     /* process the IDList */
     if (sei_tmp.fMask & SEE_MASK_IDLIST)
     {
-        IShellExecuteHookW* pSEH;
+        CComPtr<IShellExecuteHookW> pSEH;
 
         HRESULT hr = SHBindToParent((LPCITEMIDLIST)sei_tmp.lpIDList, IID_PPV_ARG(IShellExecuteHookW, &pSEH), NULL);
 
@@ -1790,8 +1788,6 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
         {
             hr = pSEH->Execute(&sei_tmp);
 
-            pSEH->Release();
-
             if (hr == S_OK)
             {
                 HeapFree(GetProcessHeap(), 0, wszApplicationName);
index bbecaea..c367c86 100644 (file)
@@ -212,11 +212,11 @@ static HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCWSTR pathRoot,
     if (SUCCEEDED (hr))
     {
         LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
-        IPersistFolder *pPF;
-        IPersistFolder3 *ppf;
+        CComPtr<IPersistFolder> ppf;
+        CComPtr<IPersistFolder3> ppf3;
 
         if (_ILIsFolder(pidlChild) &&
-            SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf))))
+            SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3))))
         {
             PERSIST_FOLDER_TARGET_INFO ppfti;
 
@@ -241,13 +241,11 @@ static HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCWSTR pathRoot,
                     hr = E_INVALIDARG;
             }
 
-            ppf->InitializeEx(NULL, pidlAbsolute, &ppfti);
-            ppf->Release();
+            ppf3->InitializeEx(NULL, pidlAbsolute, &ppfti);
         }
-        else if (SUCCEEDED((hr = pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder, &pPF)))))
+        else if (SUCCEEDED((hr = pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder, &ppf)))))
         {
-            pPF->Initialize(pidlAbsolute);
-            pPF->Release();
+            ppf->Initialize(pidlAbsolute);
         }
         ILFree (pidlAbsolute);
     }
@@ -280,7 +278,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
                              LPCWSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut)
 {
     GUID const *clsid;
-    IShellFolder *pSF;
+    CComPtr<IShellFolder> pSF;
     HRESULT hr;
     LPITEMIDLIST pidlChild;
 
@@ -325,7 +323,6 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
             /* go deeper */
             hr = pSF->BindToObject(ILGetNext (pidlComplete), NULL, riid, ppvOut);
         }
-        pSF->Release();
     }
 
     TRACE ("-- returning (%p) %08x\n", *ppvOut, hr);
@@ -359,7 +356,7 @@ HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf,
     pidlFirst = ILCloneFirst(pidl);
     if (pidlFirst)
     {
-        IShellFolder *psfChild;
+        CComPtr<IShellFolder> psfChild;
 
         hr = psf->BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild));
         if (SUCCEEDED (hr))
@@ -373,7 +370,6 @@ HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf,
                 if(!StrRetToStrNW (szOut, dwOutLen, &strTemp, pidlNext))
                     hr = E_FAIL;
             }
-            psfChild->Release();
         }
         ILFree (pidlFirst);
     } else
@@ -491,7 +487,7 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO
 
         if (SFGAO_HASSUBFOLDER & *pdwAttributes)
         {
-            IShellFolder *psf2;
+            CComPtr<IShellFolder> psf2;
             if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
             {
                 IEnumIDList *pEnumIL = NULL;
@@ -501,7 +497,6 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO
                         *pdwAttributes &= ~SFGAO_HASSUBFOLDER;
                     pEnumIL->Release();
                 }
-                psf2->Release();
             }
         }
     } else
@@ -514,68 +509,73 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO
 /***********************************************************************
  *  SHELL32_CompareIDs
  */
-HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
+HRESULT SHELL32_CompareIDs(IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
 {
     int type1,
-      type2;
+        type2;
     char szTemp1[MAX_PATH];
     char szTemp2[MAX_PATH];
     HRESULT nReturn;
-    LPITEMIDLIST firstpidl,
-      nextpidl1,
-      nextpidl2;
-    IShellFolder *psf;
+    LPITEMIDLIST firstpidl;
+    LPITEMIDLIST nextpidl1;
+    LPITEMIDLIST nextpidl2;
+    CComPtr<IShellFolder> psf;
 
     /* test for empty pidls */
-    BOOL isEmpty1 = _ILIsDesktop (pidl1);
-    BOOL isEmpty2 = _ILIsDesktop (pidl2);
+    BOOL isEmpty1 = _ILIsDesktop(pidl1);
+    BOOL isEmpty2 = _ILIsDesktop(pidl2);
 
     if (isEmpty1 && isEmpty2)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 0 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
     if (isEmpty1)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (WORD) -1);
     if (isEmpty2)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
 
     /* test for different types. Sort order is the PT_* constant */
-    type1 = _ILGetDataPointer (pidl1)->type;
-    type2 = _ILGetDataPointer (pidl2)->type;
+    type1 = _ILGetDataPointer(pidl1)->type;
+    type2 = _ILGetDataPointer(pidl2)->type;
     if (type1 < type2)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (WORD) -1);
     else if (type1 > type2)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
 
     /* test for name of pidl */
-    _ILSimpleGetText (pidl1, szTemp1, MAX_PATH);
-    _ILSimpleGetText (pidl2, szTemp2, MAX_PATH);
-    nReturn = lstrcmpiA (szTemp1, szTemp2);
+    _ILSimpleGetText(pidl1, szTemp1, MAX_PATH);
+    _ILSimpleGetText(pidl2, szTemp2, MAX_PATH);
+    nReturn = lstrcmpiA(szTemp1, szTemp2);
     if (nReturn < 0)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (WORD) -1);
     else if (nReturn > 0)
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
 
     /* test of complex pidls */
-    firstpidl = ILCloneFirst (pidl1);
-    nextpidl1 = ILGetNext (pidl1);
-    nextpidl2 = ILGetNext (pidl2);
+    firstpidl = ILCloneFirst(pidl1);
+    nextpidl1 = ILGetNext(pidl1);
+    nextpidl2 = ILGetNext(pidl2);
 
     /* optimizing: test special cases and bind not deeper */
     /* the deeper shellfolder would do the same */
-    isEmpty1 = _ILIsDesktop (nextpidl1);
-    isEmpty2 = _ILIsDesktop (nextpidl2);
-
-    if (isEmpty1 && isEmpty2) {
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 0 );
-    } else if (isEmpty1) {
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
-    } else if (isEmpty2) {
-        return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
-    /* optimizing end */
-    } else if (SUCCEEDED (iface->BindToObject(firstpidl, NULL, IID_PPV_ARG(IShellFolder, &psf)))) {
-    nReturn = psf->CompareIDs(lParam, nextpidl1, nextpidl2);
-    psf->Release();
+    isEmpty1 = _ILIsDesktop(nextpidl1);
+    isEmpty2 = _ILIsDesktop(nextpidl2);
+
+    if (isEmpty1 && isEmpty2) 
+    {
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
+    }
+    else if (isEmpty1) 
+    {
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (WORD) -1);
+    }
+    else if (isEmpty2)
+    {
+        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
+        /* optimizing end */
+    }
+    else if (SUCCEEDED(iface->BindToObject(firstpidl, NULL, IID_PPV_ARG(IShellFolder, &psf)))) {
+        nReturn = psf->CompareIDs(lParam, nextpidl1, nextpidl2);
     }
-    ILFree (firstpidl);
+    ILFree(firstpidl);
     return nReturn;
 }
 
@@ -584,10 +584,10 @@ HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST p
  *
  *   Undocumented.
  */
-HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, LPDATAOBJECT lpDataObject,
+HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, IDataObject * lpDataObject,
                               UINT uFlags, LPITEMIDLIST *lppidlLinks)
 {
-    FIXME("%p %s %p %08x %p\n",hWnd,lpszDir,lpDataObject,uFlags,lppidlLinks);
+    FIXME("%p %s %p %08x %p\n", hWnd, lpszDir, lpDataObject, uFlags, lppidlLinks);
     return E_NOTIMPL;
 }
 
index ee3dd03..decb830 100644 (file)
@@ -1755,7 +1755,7 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl
 
             if (GetSelections())
             {
-                IDataObject * pda;
+                CComPtr<IDataObject> pda;
                 DWORD dwAttributes = SFGAO_CANLINK;
                 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
 
@@ -1775,14 +1775,12 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl
                     if (SUCCEEDED(pda->QueryInterface(IID_PPV_ARG(IAsyncOperation, &piaso))))
                     {
                         piaso->SetAsyncMode(TRUE);
-                        piaso->Release();
                     }
 
                     if (pds)
                     {                        DWORD dwEffect2;
                         DoDragDrop(pda, pds, dwEffect, &dwEffect2);
                     }
-                    pda->Release();
                 }
             }
             break;