ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

shellservices.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2005 Martin Fuchs
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 
00020  //
00021  // Explorer clone
00022  //
00023  // shellservices.cpp
00024  //
00025  // Martin Fuchs, 28.03.2005
00026  //
00027 
00028 
00029 #include <precomp.h>
00030 
00031 #include "shellservices.h"
00032 
00033 
00034 int SSOThread::Run()
00035 {
00036     ComInit usingCOM(COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE|COINIT_SPEED_OVER_MEMORY);
00037 
00038     HKEY hkey;
00039     CLSID clsid;
00040     WCHAR name[MAX_PATH], value[MAX_PATH];
00041 
00042     typedef vector<SIfacePtr<IOleCommandTarget>*> SSOVector;
00043     SSOVector sso_ptrs;
00044 
00045     if (!RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad"), &hkey)) {
00046         for(int idx=0; ; ++idx) {
00047             DWORD name_len = MAX_PATH;
00048             DWORD value_len = sizeof(value);
00049 
00050             if (RegEnumValueW(hkey, idx, name, &name_len, 0, NULL, (LPBYTE)&value, &value_len))
00051                 break;
00052 
00053             if (!_alive)
00054                 break;
00055 
00056             SIfacePtr<IOleCommandTarget>* sso_ptr = new SIfacePtr<IOleCommandTarget>;
00057 
00058             if (CLSIDFromString(value, &clsid) == NOERROR) {
00059                 if (SUCCEEDED(sso_ptr->CreateInstance(clsid, IID_IOleCommandTarget))) {
00060                     if (SUCCEEDED((*sso_ptr)->Exec(&CGID_ShellServiceObject, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL)))
00061                         sso_ptrs.push_back(sso_ptr);
00062                 }
00063             }
00064         }
00065 
00066         RegCloseKey(hkey);
00067     }
00068 
00069     if (!sso_ptrs.empty()) {
00070         MSG msg;
00071 
00072         while(_alive) {
00073             if (MsgWaitForMultipleObjects(1, &_evtFinish, FALSE, INFINITE, QS_ALLINPUT) == WAIT_OBJECT_0+0)
00074                 break;  // _evtFinish has been set.
00075 
00076             while(_alive) {
00077                 if (!PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
00078                     break;
00079 
00080                 if (msg.message == WM_QUIT)
00081                     break;
00082 
00083                 TranslateMessage(&msg);
00084                 DispatchMessage(&msg);
00085             }
00086         }
00087 
00088          // shutdown all running Shell Service Objects
00089         for(SSOVector::iterator it=sso_ptrs.begin(); it!=sso_ptrs.end(); ++it) {
00090             SIfacePtr<IOleCommandTarget>* sso_ptr = *it;
00091             (*sso_ptr)->Exec(&CGID_ShellServiceObject, OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
00092             delete sso_ptr;
00093         }
00094     }
00095 
00096     return 0;
00097 }

Generated on Sun May 27 2012 04:18:31 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.