diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index ad412dc5117..ac711e6fc24 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -166,18 +166,18 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL #endif // If there is given the command line option "-desktop", create desktop window anyways - if (!lstrcmp(lpCmdLine,TEXT("-desktop"))) + if (_tcsstr(lpCmdLine,TEXT("-desktop"))) startup_desktop = TRUE; - if (!lstrcmp(lpCmdLine,TEXT("-nodesktop"))) + if (_tcsstr(lpCmdLine,TEXT("-nodesktop"))) startup_desktop = FALSE; - if (!lstrcmp(lpCmdLine,TEXT("-noexplorer"))) { + if (_tcsstr(lpCmdLine,TEXT("-noexplorer"))) { nShowCmd = SW_HIDE; startup_desktop = TRUE; } - if (!lstrcmp(lpCmdLine,TEXT("-noautostart"))) + if (!_tcsstr(lpCmdLine,TEXT("-noautostart"))) autostart = false; g_Globals._hInstance = hInstance; diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index b64965c191b..bf08ab4efbd 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -319,7 +319,11 @@ void ShellBrowserChild::InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShe SendMessage(_left_hwnd, WM_SETREDRAW, FALSE, 0); - entry->smart_scan(); + try { + entry->smart_scan(); + } catch(COMException& e) { + HandleException(e, g_Globals._hMainWnd); + } TV_ITEM tvItem; TV_INSERTSTRUCT tvInsert; @@ -486,7 +490,11 @@ HRESULT ShellBrowserChild::OnDefaultCommand(IShellView* ppshv) ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel); if (parent) { - parent->smart_scan(); + try { + parent->smart_scan(); + } catch(COMException& e) { + return e.Error(); + } Entry* entry = parent->find_entry(pidl); diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp index c1cad0d96fa..51fffb0c910 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp @@ -51,6 +51,8 @@ QuickLaunchMap::~QuickLaunchMap() QuickLaunchBar::QuickLaunchBar(HWND hwnd) : super(hwnd) { + _dir = NULL; + _next_id = IDC_FIRST_QUICK_ID; HWND hwndToolTip = (HWND) SendMessage(hwnd, TB_GETTOOLTIPS, 0, 0); @@ -93,11 +95,12 @@ void QuickLaunchBar::AddShortcuts() _stprintf(path, _T("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data); _dir = new ShellDirectory(Desktop(), path, _hwnd); + + _dir->smart_scan(); } catch(COMException&) { return; } - _dir->smart_scan(); ShellFolder desktop_folder; WindowCanvas canvas(_hwnd); diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index e51cef2cc5d..a1945b8e5fc 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -125,7 +125,11 @@ void StartMenu::AddEntries() StartMenuDirectory& smd = *it; ShellDirectory& dir = smd._dir; - dir.smart_scan(); + try { + dir.smart_scan(); + } catch(COMException& e) { + HandleException(e, g_Globals._hMainWnd); + } AddShellEntries(dir, -1, smd._subfolders); } @@ -389,31 +393,38 @@ void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, CREAT void StartMenu::CreateSubmenu(int id, int folder_id, CREATORFUNC creator) { - StartMenuFolders new_folders; + try { + SpecialFolderPath folder(folder_id, _hwnd); - SpecialFolderPath folder(folder_id, _hwnd); - - if (folder) + StartMenuFolders new_folders; new_folders.push_back(folder); - CreateSubmenu(id, new_folders, creator); + CreateSubmenu(id, new_folders, creator); + } catch(COMException&) { + // ignore Exception and don't display anything + } } void StartMenu::CreateSubmenu(int id, int folder_id1, int folder_id2, CREATORFUNC creator) { StartMenuFolders new_folders; - SpecialFolderPath folder1(folder_id1, _hwnd); + try { + SpecialFolderPath folder1(folder_id1, _hwnd); - if (folder1) new_folders.push_back(folder1); + } catch(COMException&) { + } - SpecialFolderPath folder2(folder_id2, _hwnd); + try { + SpecialFolderPath folder2(folder_id2, _hwnd); - if (folder2) new_folders.push_back(folder2); + } catch(COMException&) { + } - CreateSubmenu(id, new_folders, creator); + if (!new_folders.empty()) + CreateSubmenu(id, new_folders, creator); } @@ -540,13 +551,21 @@ void StartMenuButton::DrawItem(LPDRAWITEMSTRUCT dis) StartMenuRoot::StartMenuRoot(HWND hwnd) : super(hwnd) { - // insert directory "All Users\Start Menu" - ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd); - _dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders + try { + // insert directory "All Users\Start Menu" + ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd); + _dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders + } catch(COMException&) { + // ignore exception and don't show additional shortcuts + } - // insert directory "\Start Menu" - ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd); - _dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders + try { + // insert directory "\Start Menu" + ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd); + _dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders + } catch(COMException&) { + // ignore exception and don't show additional shortcuts + } // read size of logo bitmap BITMAP bmp_hdr; @@ -839,7 +858,11 @@ void RecentStartMenu::AddEntries() StartMenuDirectory& smd = *it; ShellDirectory& dir = smd._dir; - dir.smart_scan(); + try { + dir.smart_scan(); + } catch(COMException& e) { + HandleException(e, g_Globals._hMainWnd); + } dir.sort_directory(SORT_DATE); AddShellEntries(dir, 16, smd._subfolders); //TODO: read max. count of entries from registry diff --git a/reactos/subsys/system/explorer/utility/shellclasses.cpp b/reactos/subsys/system/explorer/utility/shellclasses.cpp index cf8f13949f7..5870716ed3f 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.cpp +++ b/reactos/subsys/system/explorer/utility/shellclasses.cpp @@ -164,6 +164,9 @@ ShellFolder::ShellFolder(IShellFolder* parent, LPCITEMIDLIST pidl) { IShellFolder* ptr; + if (!pidl) + CheckError(E_INVALIDARG); + if (pidl && pidl->mkid.cb) CheckError(parent->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&ptr)); else diff --git a/reactos/subsys/system/explorer/utility/shellclasses.h b/reactos/subsys/system/explorer/utility/shellclasses.h index 253c806cdcb..fc92ef10d57 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.h +++ b/reactos/subsys/system/explorer/utility/shellclasses.h @@ -61,6 +61,11 @@ struct COMException { } + HRESULT Error() const + { + return _hr; + } + LPCTSTR ErrorMessage() const { if (_msg.empty()) { @@ -696,7 +701,8 @@ struct SpecialFolderPath : public ShellPath { SpecialFolderPath(int folder, HWND hwnd) { - /*HRESULT hr = */SHGetSpecialFolderLocation(hwnd, folder, &_p); + HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p); + CheckError(hr); } }; @@ -745,6 +751,7 @@ struct SpecialFolderFSPath : public FileSysShellPath SpecialFolderFSPath(int folder, HWND hwnd) { HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p); + CheckError(hr); } };