[RSHELL]
authorDavid Quintana <gigaherz@gmail.com>
Mon, 3 Mar 2014 16:11:47 +0000 (16:11 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Mon, 3 Mar 2014 16:11:47 +0000 (16:11 +0000)
* Improve logging in case of unexpected failures, and trace the creation of toolbar (menu) items.
CORE-7586

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

13 files changed:
base/shell/rshell/CMenuBand.cpp
base/shell/rshell/CMenuDeskBar.cpp
base/shell/rshell/CMenuFocusManager.cpp
base/shell/rshell/CMenuSite.cpp
base/shell/rshell/CMenuToolbars.cpp
base/shell/rshell/CMergedFolder.cpp
base/shell/rshell/CStartMenu.cpp
base/shell/rshell/logging/CMenuBandWrap.cpp
base/shell/rshell/logging/CMenuDeskBarWrap.cpp
base/shell/rshell/logging/CMenuSiteWrap.cpp
base/shell/rshell/logging/CStartMenuSiteWrap.cpp
base/shell/rshell/precomp.h
base/shell/rshell/wraplog.cpp

index 5f27441..272c130 100644 (file)
@@ -40,7 +40,7 @@ HRESULT WINAPI CMenuBand_Constructor(REFIID riid, LPVOID *ppv)
 
     HRESULT hr = site->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         site->Release();
 
     return hr;
@@ -126,7 +126,7 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetMenu(
     m_menuOwner;
 
     HRESULT hr = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (m_site)
@@ -134,11 +134,11 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetMenu(
         HWND hwndParent;
 
         hr = m_site->GetWindow(&hwndParent);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = m_staticToolbar->FillToolbar();
@@ -170,11 +170,11 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetSite(IUnknown *pUnkSite)
 
     hwndParent = NULL;
     hr = pUnkSite->QueryInterface(IID_PPV_ARG(IOleWindow, &m_site));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = m_site->GetWindow(&hwndParent);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (!::IsWindow(hwndParent))
@@ -183,32 +183,32 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetSite(IUnknown *pUnkSite)
     if (m_staticToolbar != NULL)
     {
         hr = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = m_staticToolbar->FillToolbar();
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
 
     if (m_SFToolbar != NULL)
     {
         hr = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = m_SFToolbar->FillToolbar();
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
 
     hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup, &m_subMenuParent));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     CComPtr<IOleWindow> pTopLevelWindow;
     hr = IUnknown_QueryService(m_site, SID_STopLevelBrowser, IID_PPV_ARG(IOleWindow, &pTopLevelWindow));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return pTopLevelWindow->GetWindow(&m_topLevelWindow);
@@ -242,12 +242,12 @@ HRESULT STDMETHODCALLTYPE CMenuBand::OnPosRectChangeDB(RECT *prc)
 
     if (m_staticToolbar != NULL)
         hr = m_staticToolbar->GetIdealSize(sizeStatic);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (m_SFToolbar != NULL)
         hr = m_SFToolbar->GetIdealSize(sizeShlFld);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (m_staticToolbar == NULL && m_SFToolbar == NULL)
@@ -289,12 +289,12 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::GetBandInfo(
 
     if (m_staticToolbar != NULL)
         hr = m_staticToolbar->GetIdealSize(sizeStatic);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (m_SFToolbar != NULL)
         hr = m_SFToolbar->GetIdealSize(sizeShlFld);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (m_staticToolbar == NULL && m_SFToolbar == NULL)
@@ -312,17 +312,17 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::ShowDW(BOOL fShow)
 
     if (m_staticToolbar != NULL)
         hr = m_staticToolbar->ShowWindow(fShow);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
     if (m_SFToolbar != NULL)
         hr = m_SFToolbar->ShowWindow(fShow);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (fShow)
     {
         hr = _CallCB(SMC_INITMENU, 0, 0);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
 
@@ -363,18 +363,18 @@ HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
     HRESULT hr;
 
     hr = m_subMenuParent->SetSubMenu(this, fActivate);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (fActivate)
     {
         CComPtr<IOleWindow> pTopLevelWindow;
         hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IOleWindow, &pTopLevelWindow));
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = pTopLevelWindow->GetWindow(&m_topLevelWindow);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
     else
@@ -497,7 +497,7 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMID
     }
 
     HRESULT hr = m_SFToolbar->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (m_site)
@@ -505,11 +505,11 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMID
         HWND hwndParent;
 
         hr = m_site->GetWindow(&hwndParent);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         hr = m_SFToolbar->FillToolbar();
@@ -719,7 +719,7 @@ HRESULT CMenuBand::_OnPopupSubMenu(IMenuPopup * popup, POINTL * pAt, RECTL * pEx
     if (m_subMenuChild)
     {
         HRESULT hr = m_subMenuChild->OnSelect(MPOS_CANCELLEVEL);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
     if (m_staticToolbar) m_staticToolbar->OnPopupItemChanged(toolbar, item);
index bbacac0..d9007d1 100644 (file)
@@ -39,7 +39,7 @@ HRESULT WINAPI CMenuDeskBar_Constructor(REFIID riid, LPVOID *ppv)
 
     HRESULT hr = deskbar->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         deskbar->Release();
 
     return hr;
@@ -79,7 +79,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnFocusChangeIS(IUnknown *punkObj, BOOL
     CComPtr<IInputObjectSite> ios;
 
     HRESULT hr = m_Client->QueryInterface(IID_PPV_ARG(IInputObjectSite, &ios));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return ios->OnFocusChangeIS(punkObj, fSetFocus);
@@ -150,7 +150,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::HasFocusIO()
     CComPtr<IInputObject> io;
 
     HRESULT hr = m_Client->QueryInterface(IID_PPV_ARG(IInputObject, &io));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return io->HasFocusIO();
@@ -161,7 +161,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::TranslateAcceleratorIO(LPMSG lpMsg)
     CComPtr<IInputObject> io;
 
     HRESULT hr = m_Client->QueryInterface(IID_PPV_ARG(IInputObject, &io));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return io->TranslateAcceleratorIO(lpMsg);
@@ -183,15 +183,15 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetClient(IUnknown *punkClient)
     }
 
     hr = punkClient->QueryInterface(IID_PPV_ARG(IUnknown, &m_Client));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = m_Client->QueryInterface(IID_PPV_ARG(IDeskBarClient, &pDeskBandClient));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = pDeskBandClient->SetDeskBarSite(static_cast<IDeskBar*>(this));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return IUnknown_GetWindow(m_Client, &m_ClientWindow);
@@ -250,11 +250,11 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::Popup(POINTL *ppt, RECTL *prcExclude, MP
         return E_FAIL;
 
     hr = IUnknown_QueryService(m_Client, SID_SMenuBandChild, IID_PPV_ARG(IOleCommandTarget, &oct));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = m_Client->QueryInterface(IID_PPV_ARG(IDeskBarClient, &dbc));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     // Windows calls this, but it appears to be unimplemented?
@@ -263,12 +263,12 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::Popup(POINTL *ppt, RECTL *prcExclude, MP
 
     // No clue about the arg, using anything != 0
     hr = dbc->UIActivateDBC(TRUE);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     RECT rc = { 0 };
     hr = dbc->GetSize(0, &rc);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     // Unknown meaning
@@ -276,7 +276,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::Popup(POINTL *ppt, RECTL *prcExclude, MP
     const int CMD_EXEC_OPT = 0;
 
     hr = IUnknown_QueryServiceExec(m_Client, SID_SMenuBandChild, &CLSID_MenuBand, CMD, CMD_EXEC_OPT, NULL, NULL);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     ::AdjustWindowRect(&rc, ::GetWindowLong(m_hWnd, GWL_STYLE), FALSE);
@@ -372,7 +372,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetIconSize(THIS_ DWORD iIcon)
     const int CMD_EXEC_OPT = iIcon ? 0 : 2; // seems to work
 
     hr = IUnknown_QueryServiceExec(m_Client, SID_SMenuBandChild, &CLSID_MenuBand, CMD, CMD_EXEC_OPT, NULL, NULL);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     BOOL bHandled;
@@ -479,16 +479,16 @@ HRESULT CMenuDeskBar::_CloseBar()
     if (m_SubMenuChild)
     {
         hr = m_SubMenuChild->OnSelect(MPOS_CANCELLEVEL);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
 
     hr = m_Client->QueryInterface(IID_PPV_ARG(IDeskBarClient, &dbc));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = dbc->UIActivateDBC(FALSE);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     SetWindowPos(m_hWnd, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
@@ -506,7 +506,7 @@ BOOL CMenuDeskBar::_IsSubMenuParent(HWND hwnd)
         CComPtr<IOleWindow> window;
 
         hr = popup->QueryInterface(IID_PPV_ARG(IOleWindow, &window));
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return FALSE;
 
         HWND parent;
@@ -517,7 +517,7 @@ BOOL CMenuDeskBar::_IsSubMenuParent(HWND hwnd)
 
         popup = NULL;
         hr = IUnknown_GetSite(window, IID_PPV_ARG(IMenuPopup, &popup));
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return FALSE;
     }
 
@@ -552,14 +552,14 @@ LRESULT CMenuDeskBar::_OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
 
     CComPtr<IWinEventHandler> winEventHandler;
     HRESULT hr = m_Client->QueryInterface(IID_PPV_ARG(IWinEventHandler, &winEventHandler));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return 0;
 
     if (winEventHandler)
     {
         LRESULT result;
         hr = winEventHandler->OnWinEvent(NULL, uMsg, wParam, lParam, &result);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return 0;
         return result;
     }
@@ -615,13 +615,13 @@ LRESULT CMenuDeskBar::_OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
     // HACK! I just want it to work !!!
     CComPtr<IDeskBar> db;
     HRESULT hr = IUnknown_QueryService(m_Client, SID_SMenuBandChild, IID_PPV_ARG(IDeskBar, &db));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return 0;
 
     CComPtr<IUnknown> punk;
 
     hr = db->GetClient(&punk);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return 0;
 
     if (!punk && m_Shown)
index 56b2759..ced842a 100644 (file)
@@ -207,13 +207,13 @@ HRESULT CMenuFocusManager::UpdateFocus(CMenuBand * newBand)
     }
 
     hr = newBand->_GetTopLevelWindow(&newFocus);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (!m_currentBand)
     {
         hr = PlaceHooks(newFocus);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
 
@@ -228,7 +228,7 @@ HRESULT CMenuFocusManager::PushMenu(CMenuBand * mb)
     HRESULT hr;
 
     hr = PushToArray(mb);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return UpdateFocus(mb);
@@ -240,7 +240,7 @@ HRESULT CMenuFocusManager::PopMenu(CMenuBand * mb)
     HRESULT hr;
 
     hr = PopFromArray(&mbc);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (mb != mbc)
index beba7ba..367909c 100644 (file)
@@ -37,7 +37,7 @@ HRESULT WINAPI CMenuSite_Constructor(REFIID riid, LPVOID *ppv)
 
     HRESULT hr = site->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         site->Release();
 
     return hr;
@@ -109,7 +109,7 @@ HRESULT STDMETHODCALLTYPE CMenuSite::AddBand(IUnknown * punk)
     if (m_BandObject)
     {
         hr = IUnknown_SetSite(m_BandObject, NULL);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
     }
 
@@ -122,19 +122,19 @@ HRESULT STDMETHODCALLTYPE CMenuSite::AddBand(IUnknown * punk)
         return TO_HRESULT(0);
 
     hr = punk->QueryInterface(IID_PPV_ARG(IDeskBand, &m_DeskBand));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = punk->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_WinEventHandler));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = IUnknown_SetSite(punk, this->ToIUnknown());
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = IUnknown_GetWindow(punk, &m_hWndBand);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     m_BandObject = punk;
index d2ba80d..fba57b0 100644 (file)
@@ -457,11 +457,11 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
 #else
     hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite));
 #endif
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #if WRAP_MENUSITE
     hr = CMenuSite_Wrapper(pBandSite, IID_PPV_ARG(IBandSite, &pBandSite));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
@@ -473,25 +473,25 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
 #else
     hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar));
 #endif
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #if WRAP_MENUDESKBAR
     hr = CMenuDeskBar_Wrapper(pDeskBar, IID_PPV_ARG(IDeskBar, &pDeskBar));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
     hr = pDeskBar->SetClient(pBandSite);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = pBandSite->AddBand(childShellMenu);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     CComPtr<IMenuPopup> popup;
     hr = pDeskBar->QueryInterface(IID_PPV_ARG(IMenuPopup, &popup));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     m_menuBand->_OnPopupSubMenu(popup, &pt, &rcl, this, m_popupItem);
@@ -526,7 +526,7 @@ HRESULT CMenuToolbarBase::DoContextMenu(IContextMenu* contextMenu)
         return E_FAIL;
 
     hr = contextMenu->QueryContextMenu(hPopup, 0, 0, UINT_MAX, CMF_NORMAL);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
     {
         DestroyMenu(hPopup);
         return hr;
@@ -667,7 +667,10 @@ HRESULT CMenuToolbarBase::AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSu
     tbb.iBitmap = iconId;
     tbb.dwData = buttonData;
 
-    SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb));
+    DbgPrint("Trying to add a new button with id %d and caption '%S'...\n", commandId, caption);
+
+    if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
+        return HRESULT_FROM_WIN32(GetLastError());
 
     return S_OK;
 }
@@ -684,7 +687,10 @@ HRESULT CMenuToolbarBase::AddSeparator(BOOL last)
     tbb.fsStyle = BTNS_SEP;
     tbb.iBitmap = 0;
 
-    SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb));
+    DbgPrint("Trying to add a new separator...\n");
+
+    if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
+        return HRESULT_FROM_WIN32(GetLastError());
 
     return S_OK;
 }
@@ -699,7 +705,10 @@ HRESULT CMenuToolbarBase::AddPlaceholder()
     tbb.iString = (INT_PTR) MenuString;
     tbb.iBitmap = -1;
 
-    SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb));
+    DbgPrint("Trying to add a new placeholder...\n");
+
+    if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
+        return HRESULT_FROM_WIN32(GetLastError());
 
     return S_OK;
 }
@@ -790,12 +799,23 @@ HRESULT CMenuStaticToolbar::FillToolbar()
 
         info.cbSize = sizeof(info);
         info.dwTypeData = NULL;
-        info.fMask = MIIM_FTYPE | MIIM_STRING;
+        info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID;
 
-        GetMenuItemInfoW(m_hmenu, i, TRUE, &info);
+        if (!GetMenuItemInfoW(m_hmenu, i, TRUE, &info))
+        {
+            DbgPrint("Error obtaining info for menu item at pos=%d\n", i);
+            continue;
+        }
+
+        DbgPrint("Found item with fType=%x, cmdId=%d\n", info.fType, info.wID);
 
-        if (info.fType == MFT_STRING)
+        if (info.fType & MFT_SEPARATOR)
+        {
+            AddSeparator(last);
+        }
+        else // if (info.fType == MFT_STRING)
         {
+
             info.cch++;
             info.dwTypeData = (PWSTR) HeapAlloc(GetProcessHeap(), 0, (info.cch + 1) * sizeof(WCHAR));
 
@@ -807,17 +827,13 @@ HRESULT CMenuStaticToolbar::FillToolbar()
             // FIXME: remove before deleting the toolbar or it will leak
 
             HRESULT hr = m_menuBand->_CallCBWithItemId(info.wID, SMC_GETINFO, 0, reinterpret_cast<LPARAM>(sminfo));
-            if (FAILED(hr))
+            if (FAILED_UNEXPECTEDLY(hr))
                 return hr;
 
             AddButton(info.wID, info.dwTypeData, info.hSubMenu != NULL, sminfo->iIcon, reinterpret_cast<DWORD_PTR>(sminfo), last);
 
             HeapFree(GetProcessHeap(), 0, info.dwTypeData);
         }
-        else
-        {
-            AddSeparator(last);
-        }
     }
 
     return S_OK;
@@ -837,7 +853,7 @@ HRESULT CMenuStaticToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *the
 {
     HRESULT hr;
     hr = CMenuToolbarBase::OnCommand(wParam, lParam, theResult);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     // in case the clicked item has a submenu, we do not need to execute the item
@@ -861,7 +877,7 @@ HRESULT CMenuStaticToolbar::InternalPopupItem(INT uItem, INT index, DWORD_PTR dw
     {
         CComPtr<IShellMenu> shellMenu;
         HRESULT hr = m_menuBand->_CallCBWithItemId(uItem, SMC_GETOBJECT, reinterpret_cast<WPARAM>(&IID_IShellMenu), reinterpret_cast<LPARAM>(&shellMenu));
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         return PopupSubMenu(uItem, index, shellMenu);
@@ -903,7 +919,7 @@ HRESULT CMenuSFToolbar::FillToolbar()
         STRRET sr = { STRRET_CSTR, { 0 } };
 
         hr = m_shellFolder->GetDisplayNameOf(item, SIGDN_NORMALDISPLAY, &sr);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
         StrRetToStr(&sr, NULL, &MenuString);
@@ -950,7 +966,7 @@ HRESULT CMenuSFToolbar::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REF
     HRESULT hr;
 
     hr = m_shellFolder->QueryInterface(riid, ppv);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (pdwFlags)
@@ -993,7 +1009,7 @@ HRESULT CMenuSFToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResu
 {
     HRESULT hr;
     hr = CMenuToolbarBase::OnCommand(wParam, lParam, theResult);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     // in case the clicked item has a submenu, we do not need to execute the item
@@ -1028,11 +1044,11 @@ HRESULT CMenuSFToolbar::InternalPopupItem(INT uItem, INT index, DWORD_PTR dwData
 #else
     hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &shellMenu));
 #endif
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #if WRAP_MENUBAND
     hr = CMenuBand_Wrapper(shellMenu, IID_PPV_ARG(IShellMenu, &shellMenu));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
@@ -1040,16 +1056,16 @@ HRESULT CMenuSFToolbar::InternalPopupItem(INT uItem, INT index, DWORD_PTR dwData
 
     // FIXME: not sure what to use as uId/uIdAncestor here
     hr = shellMenu->Initialize(psmc, 0, uId, SMINIT_VERTICAL);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     CComPtr<IShellFolder> childFolder;
     hr = m_shellFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &childFolder));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = shellMenu->SetShellFolder(childFolder, NULL, NULL, 0);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return PopupSubMenu(uItem, index, shellMenu);
@@ -1062,7 +1078,7 @@ HRESULT CMenuSFToolbar::InternalHasSubMenu(INT uItem, INT index, DWORD_PTR dwDat
 
     SFGAOF attrs = SFGAO_FOLDER;
     hr = m_shellFolder->GetAttributesOf(1, &pidl, &attrs);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return (attrs & SFGAO_FOLDER) ? S_OK : S_FALSE;
index 02d708c..6d1c35b 100644 (file)
@@ -49,10 +49,10 @@ public:
     {
         HRESULT hr;
         hr = userLocal->EnumObjects(hwndOwner, flags, &m_UserLocal);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
         hr = userLocal->EnumObjects(hwndOwner, flags, &m_AllUSers);
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
         {
             m_UserLocal = NULL;
             return hr;
@@ -73,7 +73,7 @@ public:
         if (!m_FirstDone)
         {
             hr = m_UserLocal->Next(celt, rgelt, pceltFetched);
-            if (FAILED(hr))
+            if (FAILED_UNEXPECTEDLY(hr))
                 return hr;
             if (hr == S_FALSE)
                 m_FirstDone = true;
@@ -89,7 +89,7 @@ public:
             *pceltFetched = 0;
 
             hr = m_AllUSers->Next(celt, rgelt, pceltFetched);
-            if (FAILED(hr))
+            if (FAILED_UNEXPECTEDLY(hr))
                 return hr;
 
             *pceltFetched += offset;
@@ -138,7 +138,7 @@ HRESULT WINAPI CMergedFolder_Constructor(IShellFolder* userLocal, IShellFolder*
     hr = fld->_SetSources(userLocal, allUsers);
 
     hr = fld->QueryInterface(riid, ppv);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         fld->Release();
 
     return hr;
index 8312b56..fa10931 100644 (file)
@@ -156,11 +156,11 @@ private:
 #else
         hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &pShellMenu));
 #endif
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 #if WRAP_MENUBAND
         hr = CMenuBand_Wrapper(pShellMenu, IID_PPV_ARG(IShellMenu, &pShellMenu));
-        if (FAILED(hr))
+        if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 #endif
 
@@ -304,11 +304,11 @@ CStartMenu_Constructor(REFIID riid, void **ppv)
 #else
     hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &pShellMenu));
 #endif
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #if WRAP_MENUBAND
     hr = CMenuBand_Wrapper(pShellMenu, IID_PPV_ARG(IShellMenu, &pShellMenu));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
@@ -320,11 +320,11 @@ CStartMenu_Constructor(REFIID riid, void **ppv)
 #else
     hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite));
 #endif
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #if WRAP_MENUSITE
     hr = CMenuSite_Wrapper(pBandSite, IID_PPV_ARG(IBandSite, &pBandSite));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
@@ -336,23 +336,23 @@ CStartMenu_Constructor(REFIID riid, void **ppv)
 #else
     hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar));
 #endif
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #if WRAP_MENUDESKBAR
     hr = CMenuDeskBar_Wrapper(pDeskBar, IID_PPV_ARG(IDeskBar, &pDeskBar));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
     CComObject<CShellMenuCallback> *pCallback;
     hr = CComObject<CShellMenuCallback>::CreateInstance(&pCallback);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
     pCallback->AddRef(); // CreateInstance returns object with 0 ref count */
     pCallback->Initialize(pShellMenu, pBandSite, pDeskBar);
 
     pShellMenu->Initialize(pCallback, (UINT)-1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = SHGetDesktopFolder(&shellFolder);
@@ -369,24 +369,24 @@ CStartMenu_Constructor(REFIID riid, void **ppv)
 
     IShellFolder * psfMerged;
     hr = CMergedFolder_Constructor(psfStartMenuUser, psfStartMenuAll, IID_PPV_ARG(IShellFolder, &psfMerged));
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = pShellMenu->SetShellFolder(psfMerged, NULL, NULL, 0);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #else
     hr = pShellMenu->SetShellFolder(psfStartMenuUser, NULL, NULL, 0);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 #endif
 
     hr = pDeskBar->SetClient(pBandSite);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     hr = pBandSite->AddBand(pShellMenu);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     return pDeskBar->QueryInterface(riid, ppv);
index d055997..64e216f 100644 (file)
@@ -182,7 +182,7 @@ HRESULT WINAPI CMenuBand_Wrapper(IShellMenu * shellMenu, REFIID riid, LPVOID *pp
         return E_OUTOFMEMORY;
 
     hr = site->InitWrap(shellMenu);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
     {
         site->Release();
         return hr;
@@ -190,7 +190,7 @@ HRESULT WINAPI CMenuBand_Wrapper(IShellMenu * shellMenu, REFIID riid, LPVOID *pp
 
     hr = site->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         site->Release();
 
     return hr;
@@ -205,33 +205,33 @@ HRESULT CMenuBandWrap::InitWrap(IShellMenu * shellMenu)
     m_IShellMenu = shellMenu;
 
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IDeskBand, &m_IDeskBand));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IDockingWindow, &m_IDockingWindow));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IObjectWithSite, &m_IObjectWithSite));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IInputObject, &m_IInputObject));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IPersistStream, &m_IPersistStream));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IPersist, &m_IPersist));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_IMenuPopup));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IDeskBar, &m_IDeskBar));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IMenuBand, &m_IMenuBand));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IShellMenu2, &m_IShellMenu2));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = shellMenu->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_IWinEventHandler));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     //hr = shellMenu->QueryInterface(IID_PPV_ARG(IShellMenuAcc, &m_IShellMenuAcc));
     m_IShellMenuAcc = NULL;
     return hr;
index 44c1e04..69075ed 100644 (file)
@@ -121,7 +121,7 @@ HRESULT WINAPI CMenuDeskBar_Wrapper(IDeskBar * deskBar, REFIID riid, LPVOID *ppv
         return E_OUTOFMEMORY;
 
     hr = bar->InitWrap(deskBar);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
     {
         bar->Release();
         return hr;
@@ -129,7 +129,7 @@ HRESULT WINAPI CMenuDeskBar_Wrapper(IDeskBar * deskBar, REFIID riid, LPVOID *ppv
 
     hr = bar->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         bar->Release();
 
     return hr;
@@ -144,21 +144,21 @@ HRESULT CMenuDeskBarWrap::InitWrap(IDeskBar * deskBar)
     m_IDeskBar = deskBar;
 
     hr = deskBar->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_IMenuPopup));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IInputObjectSite, &m_IInputObjectSite));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IInputObject, &m_IInputObject));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IObjectWithSite, &m_IObjectWithSite));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IBanneredBar, &m_IBanneredBar));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = deskBar->QueryInterface(IID_PPV_ARG(IInitializeObject, &m_IInitializeObject));
     return hr;
 }
index c852c88..152bcbc 100644 (file)
@@ -116,7 +116,7 @@ HRESULT WINAPI CMenuSite_Wrapper(IBandSite * bandSite, REFIID riid, LPVOID *ppv)
         return E_OUTOFMEMORY;
 
     hr = site->InitWrap(bandSite);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
     {
         site->Release();
         return hr;
@@ -124,7 +124,7 @@ HRESULT WINAPI CMenuSite_Wrapper(IBandSite * bandSite, REFIID riid, LPVOID *ppv)
 
     hr = site->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         site->Release();
 
     return hr;
@@ -139,17 +139,17 @@ HRESULT CMenuSiteWrap::InitWrap(IBandSite * bandSite)
     m_IBandSite = bandSite;
 
     hr = bandSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &m_IDeskBarClient));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IInputObject, &m_IInputObject));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IInputObjectSite, &m_IInputObjectSite));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_IWinEventHandler));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
     return hr;
 }
index 11babdb..c077171 100644 (file)
@@ -82,7 +82,7 @@ HRESULT WINAPI CStartMenuSite_Wrapper(ITrayPriv * trayPriv, REFIID riid, LPVOID
         return E_OUTOFMEMORY;
 
     hr = site->InitWrap(trayPriv);
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
     {
         site->Release();
         return hr;
@@ -90,7 +90,7 @@ HRESULT WINAPI CStartMenuSite_Wrapper(ITrayPriv * trayPriv, REFIID riid, LPVOID
 
     hr = site->QueryInterface(riid, ppv);
 
-    if (FAILED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         site->Release();
 
     return hr;
@@ -105,9 +105,9 @@ HRESULT CStartMenuSiteWrap::InitWrap(ITrayPriv * bandSite)
     m_ITrayPriv = bandSite;
 
     hr = bandSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
-    if (FAILED(hr)) return hr;
+    if (FAILED_UNEXPECTEDLY(hr)) return hr;
     hr = bandSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
     return hr;
 }
index 46aa47a..2f8e877 100644 (file)
@@ -87,3 +87,9 @@ Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
 
 #define DbgPrint(fmt, ...) \
     Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
+
+#if 1
+#define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (DbgPrint("Unexpected failure %08x.\n", hr), TRUE))
+#else
+#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
+#endif
index 20aebb6..8f24bdc 100644 (file)
@@ -13,7 +13,7 @@ void WrapLogOpen()
 {
     if (openCount == 0)
     {
-        log = fopen("G:\\RShellWrap.log", "w");
+        log = fopen("C:\\RShellWrap.log", "w");
         nTemps = 0;
         callLevel = 0;
     }