Index: src/ch/MainWnd.cpp
===================================================================
diff -u -N -r8dc649003961dad64b92da67426814fb5dd862e0 -rc17c4aa7bb4c96219af4191623abe40d18e02713
--- src/ch/MainWnd.cpp	(.../MainWnd.cpp)	(revision 8dc649003961dad64b92da67426814fb5dd862e0)
+++ src/ch/MainWnd.cpp	(.../MainWnd.cpp)	(revision c17c4aa7bb4c96219af4191623abe40d18e02713)
@@ -667,200 +667,215 @@
 
 	case WM_GETCONFIG:
 		{
-			chcore::TConfig& rConfig = GetConfig();
-			ictranslate::CResourceManager& rResManager = GetResManager();
+			try
+			{
+				chcore::TConfig& rConfig = GetConfig();
+				ictranslate::CResourceManager& rResManager = GetResManager();
 
-			TShellExtMenuConfig cfgShellExt;
+				TShellExtMenuConfig cfgShellExt;
 
-			// experimental - doesn't work on all systems 
-			cfgShellExt.SetShowShortcutIcons(GetPropValue<PP_SHSHOWSHELLICONS>(rConfig));
+				// experimental - doesn't work on all systems 
+				cfgShellExt.SetShowShortcutIcons(GetPropValue<PP_SHSHOWSHELLICONS>(rConfig));
 
-			cfgShellExt.SetInterceptDragAndDrop(GetPropValue<PP_SHINTERCEPTDRAGDROP>(rConfig));
-			cfgShellExt.SetInterceptKeyboardActions(GetPropValue<PP_SHINTERCEPTKEYACTIONS>(rConfig));
-			cfgShellExt.SetInterceptCtxMenuActions(GetPropValue<PP_SHINTERCEPTCTXMENUACTIONS>(rConfig));
+				cfgShellExt.SetInterceptDragAndDrop(GetPropValue<PP_SHINTERCEPTDRAGDROP>(rConfig));
+				cfgShellExt.SetInterceptKeyboardActions(GetPropValue<PP_SHINTERCEPTKEYACTIONS>(rConfig));
+				cfgShellExt.SetInterceptCtxMenuActions(GetPropValue<PP_SHINTERCEPTCTXMENUACTIONS>(rConfig));
 
-			TShellMenuItemPtr spRootItem = cfgShellExt.GetCommandRoot();
+				TShellMenuItemPtr spRootItem = cfgShellExt.GetCommandRoot();
 
-			// what kind of menu ?
-			switch (wParam)
-			{
-			case eLocation_DragAndDropMenu:
+				// what kind of menu ?
+				switch(wParam)
 				{
-					bool bAddedAnyOption = false;
-					if(GetPropValue<PP_SHSHOWCOPY>(rConfig))
+				case eLocation_DragAndDropMenu:
 					{
-						spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING),
-							TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
-							TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject),
-							TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Copy));
-						bAddedAnyOption = true;
-					}
+						bool bAddedAnyOption = false;
+						if(GetPropValue<PP_SHSHOWCOPY>(rConfig))
+						{
+							spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING),
+								TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
+								TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject),
+								TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Copy));
+							bAddedAnyOption = true;
+						}
 
-					if(GetPropValue<PP_SHSHOWMOVE>(rConfig))
-					{
-						spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING),
-							TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move),
-							TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject),
-							TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Move));
-						bAddedAnyOption = true;
-					}
+						if(GetPropValue<PP_SHSHOWMOVE>(rConfig))
+						{
+							spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING),
+								TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move),
+								TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject),
+								TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Move));
+							bAddedAnyOption = true;
+						}
 
-					if(GetPropValue<PP_SHSHOWCOPYMOVE>(rConfig))
-					{
-						spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING),
-							TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy),
-							TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject),
-							TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), true));
-						bAddedAnyOption = true;
-					}
+						if(GetPropValue<PP_SHSHOWCOPYMOVE>(rConfig))
+						{
+							spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING),
+								TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy),
+								TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject),
+								TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), true));
+							bAddedAnyOption = true;
+						}
 
-					if(bAddedAnyOption)
-					{
-						// insert separator as an addition to other items
-						spRootItem->AddChild(boost::make_shared<TShellMenuItem>());
+						if(bAddedAnyOption)
+						{
+							// insert separator as an addition to other items
+							spRootItem->AddChild(boost::make_shared<TShellMenuItem>());
+						}
+						break;
 					}
-				}
-				break;
-			case eLocation_ContextMenu:
-				{
-					if(GetPropValue<PP_SHSHOWPASTE>(rConfig))
-					{
-						spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING),
-							TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy),
-							TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard),
-							TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), false));
-					}
 
-					if(GetPropValue<PP_SHSHOWPASTESPECIAL>(rConfig))
+				case eLocation_ContextMenu:
 					{
-						spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING),
-							TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy),
-							TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard),
-							TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), true));
-					}
+						if(GetPropValue<PP_SHSHOWPASTE>(rConfig))
+						{
+							spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING),
+								TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy),
+								TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard),
+								TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), false));
+						}
 
-					if(GetPropValue<PP_SHSHOWCOPYTO>(rConfig) || GetPropValue<PP_SHSHOWMOVETO>(rConfig) || GetPropValue<PP_SHSHOWCOPYMOVETO>(rConfig))
-					{
-						// prepare shortcuts for all menu options
-						std::vector<CString> vShortcutStrings;
-						GetPropValue<PP_SHORTCUTS>(rConfig, vShortcutStrings);
+						if(GetPropValue<PP_SHSHOWPASTESPECIAL>(rConfig))
+						{
+							spRootItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING),
+								TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy),
+								TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard),
+								TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), true));
+						}
 
-						bool bRetrieveFreeSpace = GetPropValue<PP_SHSHOWFREESPACE>(rConfig);
+						if(GetPropValue<PP_SHSHOWCOPYTO>(rConfig) || GetPropValue<PP_SHSHOWMOVETO>(rConfig) || GetPropValue<PP_SHSHOWCOPYMOVETO>(rConfig))
+						{
+							// prepare shortcuts for all menu options
+							std::vector<CString> vShortcutStrings;
+							GetPropValue<PP_SHORTCUTS>(rConfig, vShortcutStrings);
 
-						std::vector<CShortcut> vShortcuts;
+							bool bRetrieveFreeSpace = GetPropValue<PP_SHSHOWFREESPACE>(rConfig);
 
-						BOOST_FOREACH(const CString& strShortcutString, vShortcutStrings)
-						{
-							CShortcut tShortcut;
-							if(tShortcut.FromString(strShortcutString))
-							{
-								unsigned long long ullSize = 0;
+							std::vector<CShortcut> vShortcuts;
 
-								// retrieving free space might fail, but it's not critical - we just won't show the free space
-								if(bRetrieveFreeSpace && GetDynamicFreeSpace(tShortcut.m_strPath, &ullSize, NULL))
+							BOOST_FOREACH(const CString& strShortcutString, vShortcutStrings)
+							{
+								CShortcut tShortcut;
+								if(tShortcut.FromString(strShortcutString))
 								{
-									CString strNameFormat;
-									strNameFormat.Format(_T("%s (%s)"), tShortcut.m_strName, GetSizeString(ullSize));
+									unsigned long long ullSize = 0;
 
-									tShortcut.m_strName = strNameFormat;
-								}
+									// retrieving free space might fail, but it's not critical - we just won't show the free space
+									if(bRetrieveFreeSpace && GetDynamicFreeSpace(tShortcut.m_strPath, &ullSize, NULL))
+									{
+										CString strNameFormat;
+										strNameFormat.Format(_T("%s (%s)"), tShortcut.m_strName, GetSizeString(ullSize));
 
-								vShortcuts.push_back(tShortcut);
+										tShortcut.m_strName = strNameFormat;
+									}
+
+									vShortcuts.push_back(tShortcut);
+								}
+								else
+									BOOST_ASSERT(false);	// non-critical, but not very nice
 							}
-							else
-								BOOST_ASSERT(false);	// non-critical, but not very nice
-						}
 
-						if(GetPropValue<PP_SHSHOWCOPYTO>(rConfig))
-						{
-							boost::shared_ptr<TShellMenuItem> menuItem(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING)));
-							BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts)
+							if(GetPropValue<PP_SHSHOWCOPYTO>(rConfig))
 							{
-								menuItem->AddChild(boost::make_shared<TShellMenuItem>((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath,
+								boost::shared_ptr<TShellMenuItem> menuItem(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING)));
+								BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts)
+								{
+									menuItem->AddChild(boost::make_shared<TShellMenuItem>((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath,
+										TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
+										TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
+										TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false));
+								}
+
+								spRootItem->AddChild(menuItem);
+
+								// optionally separator
+								if(!vShortcuts.empty())
+									menuItem->AddChild(boost::make_shared<TShellMenuItem>());
+
+								// "Choose" menu option
+								menuItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING),
 									TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
 									TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
-									TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false));
+									TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false));
 							}
 
-							spRootItem->AddChild(menuItem);
+							if(GetPropValue<PP_SHSHOWMOVETO>(rConfig))
+							{
+								boost::shared_ptr<TShellMenuItem> menuItem(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING)));
+								BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts)
+								{
+									menuItem->AddChild(boost::make_shared<TShellMenuItem>((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath,
+										TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move),
+										TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
+										TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false));
+								}
 
-							// optionally separator
-							if(!vShortcuts.empty())
-								menuItem->AddChild(boost::make_shared<TShellMenuItem>());
+								spRootItem->AddChild(menuItem);
 
-							// "Choose" menu option
-							menuItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING),
-								TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
-								TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
-								TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false));
-						}
+								// optionally separator
+								if(!vShortcuts.empty())
+									menuItem->AddChild(boost::make_shared<TShellMenuItem>());
 
-						if(GetPropValue<PP_SHSHOWMOVETO>(rConfig))
-						{
-							boost::shared_ptr<TShellMenuItem> menuItem(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING)));
-							BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts)
-							{
-								menuItem->AddChild(boost::make_shared<TShellMenuItem>((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath,
+								// "Choose" menu option
+								menuItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING),
 									TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move),
 									TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
-									TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false));
+									TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false));
 							}
 
-							spRootItem->AddChild(menuItem);
+							if(GetPropValue<PP_SHSHOWCOPYMOVETO>(rConfig))
+							{
+								boost::shared_ptr<TShellMenuItem> menuItem(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING)));
+								BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts)
+								{
+									menuItem->AddChild(boost::make_shared<TShellMenuItem>((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath,
+										TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
+										TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
+										TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), true));
+								}
 
-							// optionally separator
-							if(!vShortcuts.empty())
-								menuItem->AddChild(boost::make_shared<TShellMenuItem>());
+								spRootItem->AddChild(menuItem);
 
-							// "Choose" menu option
-							menuItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING),
-								TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move),
-								TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
-								TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false));
-						}
+								// optionally separator
+								if(!vShortcuts.empty())
+									menuItem->AddChild(boost::make_shared<TShellMenuItem>());
 
-						if(GetPropValue<PP_SHSHOWCOPYMOVETO>(rConfig))
-						{
-							boost::shared_ptr<TShellMenuItem> menuItem(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING)));
-							BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts)
-							{
-								menuItem->AddChild(boost::make_shared<TShellMenuItem>((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath,
+								// "Choose" menu option
+								menuItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING),
 									TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
 									TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
-									TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), true));
+									TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), true));
 							}
-
-							spRootItem->AddChild(menuItem);
-
-							// optionally separator
-							if(!vShortcuts.empty())
-								menuItem->AddChild(boost::make_shared<TShellMenuItem>());
-
-							// "Choose" menu option
-							menuItem->AddChild(boost::make_shared<TShellMenuItem>(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING),
-								TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy),
-								TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto),
-								TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), true));
 						}
+
+						break;
 					}
+
+				default:
+					ASSERT(false);	// unhandled case
 				}
 
-				break;
-			default:
-				ASSERT(false);	// unhandled case
-			}
+				chcore::TConfig cfgStorage;
+				chcore::TString wstrData;
 
-			chcore::TConfig cfgStorage;
-			chcore::TString wstrData;
+				cfgShellExt.StoreInConfig(cfgStorage, _T("ShellExtCfg"));
+				cfgStorage.WriteToString(wstrData);
 
-			cfgShellExt.StoreInConfig(cfgStorage, _T("ShellExtCfg"));
-			cfgStorage.WriteToString(wstrData);
+				std::wstring strSHMName = IPCSupport::GenerateSHMName((unsigned long)lParam);
 
-			std::wstring strSHMName = IPCSupport::GenerateSHMName((unsigned long)lParam);
+				m_tCHExtharedMemory.Create(strSHMName.c_str(), wstrData);
+			}
+			catch(const std::exception& e)
+			{
+				_ASSERTE(FALSE);
+				CString strMsg;
+				strMsg.Format(L"Encountered problem trying to retrieve shell ext configuration.\nReason: %S", e.what());
+				LOG_ERROR(strMsg);
 
-			m_tCHExtharedMemory.Create(strSHMName.c_str(), wstrData);
+				return FALSE;
+			}
+
+			return TRUE;
 		}
-		break;
 
 	case WM_IDENTIFY:
 		{