ReactOS  0.4.15-dev-2956-g61e7ea5
CRegFolder Class Reference
Inheritance diagram for CRegFolder:
Collaboration diagram for CRegFolder:

Public Member Functions

 CRegFolder ()
 
 ~CRegFolder ()
 
HRESULT WINAPI Initialize (const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName)
 
virtual HRESULT WINAPI ParseDisplayName (HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
 
virtual HRESULT WINAPI EnumObjects (HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
 
virtual HRESULT WINAPI BindToObject (PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
 
virtual HRESULT WINAPI BindToStorage (PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
 
virtual HRESULT WINAPI CompareIDs (LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2)
 
virtual HRESULT WINAPI CreateViewObject (HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
 
virtual HRESULT WINAPI GetAttributesOf (UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut)
 
virtual HRESULT WINAPI GetUIObjectOf (HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
 
virtual HRESULT WINAPI GetDisplayNameOf (PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)
 
virtual HRESULT WINAPI SetNameOf (HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
 
virtual HRESULT WINAPI GetDefaultSearchGUID (GUID *pguid)
 
virtual HRESULT WINAPI EnumSearches (IEnumExtraSearch **ppenum)
 
virtual HRESULT WINAPI GetDefaultColumn (DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
 
virtual HRESULT WINAPI GetDefaultColumnState (UINT iColumn, DWORD *pcsFlags)
 
virtual HRESULT WINAPI GetDetailsEx (PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv)
 
virtual HRESULT WINAPI GetDetailsOf (PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd)
 
virtual HRESULT WINAPI MapColumnToSCID (UINT column, SHCOLUMNID *pscid)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IShellFolder
HRESULT EnumObjects ([in] HWND hwndOwner, [in] SHCONTF grfFlags, [out] IEnumIDList **ppenumIDList)
 
HRESULT BindToObject ([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
 
HRESULT BindToStorage ([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvObj)
 
HRESULT CreateViewObject ([in] HWND hwndOwner, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
 
HRESULT GetAttributesOf ([in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in, out] SFGAOF *rgfInOut)
 
HRESULT GetUIObjectOf ([in] HWND hwndOwner, [in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in] REFIID riid, [in, out, unique] UINT *prgfInOut, [out, iid_is(riid)] void **ppvOut)
 
HRESULT GetDisplayNameOf ([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Member Functions

HRESULT GetGuidItemAttributes (LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
 

Private Attributes

GUID m_guid
 
CAtlStringW m_rootPath
 
CAtlStringW m_enumKeyName
 
CComHeapPtr< ITEMIDLISTm_pidlRoot
 

Additional Inherited Members

- Public Types inherited from IShellFolder2
typedef struct IShellFolder2::SHCOLUMNIDLPSHCOLUMNID
 
typedef const SHCOLUMNIDLPCSHCOLUMNID
 
- Public Types inherited from IShellFolder
enum  tagSHGDN {
  SHGDN_NORMAL = 0, SHGDN_INFOLDER = 1, SHGDN_FOREDITING = 0x1000, SHGDN_INCLUDE_NONFILESYS = 0x2000,
  SHGDN_FORADDRESSBAR = 0x4000, SHGDN_FORPARSING = 0x8000
}
 
enum  tagSHCONTF {
  SHCONTF_FOLDERS = 32, SHCONTF_NONFOLDERS = 64, SHCONTF_INCLUDEHIDDEN = 128, SHCONTF_INIT_ON_FIRST_NEXT = 256,
  SHCONTF_NETPRINTERSRCH = 512, SHCONTF_SHAREABLE = 1024, SHCONTF_STORAGE = 2048, SHCONTF_NAVIGATION_ENUM = 0x01000,
  SHCONTF_FASTITEMS = 0x02000, SHCONTF_FLATLIST = 0x04000, SHCONTF_ENABLE_ASYNC = 0x08000, SHCONTF_INCLUDESUPERHIDDEN = 0x10000
}
 
typedef IShellFolderLPSHELLFOLDER
 
typedef enum IShellFolder::tagSHGDN SHGNO
 
typedef DWORD SHGDNF
 
typedef DWORD SHCONTF
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from IShellFolder
SFGAO_STORAGEANCESTOR typedef ULONG SFGAOF
 

Detailed Description

Definition at line 277 of file CRegFolder.cpp.

Constructor & Destructor Documentation

◆ CRegFolder()

CRegFolder::CRegFolder ( )

Definition at line 324 of file CRegFolder.cpp.

325 {
326 }

◆ ~CRegFolder()

CRegFolder::~CRegFolder ( )

Definition at line 328 of file CRegFolder.cpp.

329 {
330 }

Member Function Documentation

◆ BindToObject()

HRESULT WINAPI CRegFolder::BindToObject ( PCUIDLIST_RELATIVE  pidl,
LPBC  pbcReserved,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 423 of file CRegFolder.cpp.

424 {
425  CComPtr<IPersistFolder> pFolder;
426  HRESULT hr;
427 
428  if (!ppvOut || !pidl || !pidl->mkid.cb)
429  return E_INVALIDARG;
430 
431  *ppvOut = NULL;
432 
433  GUID *pGUID = _ILGetGUIDPointer(pidl);
434  if (!pGUID)
435  {
436  ERR("CRegFolder::BindToObject called for non guid item!\n");
437  return E_INVALIDARG;
438  }
439 
440  hr = SHELL32_BindToSF(m_pidlRoot, NULL, pidl, pGUID, riid, ppvOut);
441  if (FAILED_UNEXPECTEDLY(hr))
442  return hr;
443 
444  return S_OK;
445 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
HRESULT SHELL32_BindToSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidl, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: shlfolder.cpp:159
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG HRESULT
Definition: typedefs.h:79
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
CComHeapPtr< ITEMIDLIST > m_pidlRoot
Definition: CRegFolder.cpp:285
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112

◆ BindToStorage()

HRESULT WINAPI CRegFolder::BindToStorage ( PCUIDLIST_RELATIVE  pidl,
LPBC  pbcReserved,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 447 of file CRegFolder.cpp.

448 {
449  return E_NOTIMPL;
450 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ CompareIDs()

HRESULT WINAPI CRegFolder::CompareIDs ( LPARAM  lParam,
PCUIDLIST_RELATIVE  pidl1,
PCUIDLIST_RELATIVE  pidl2 
)
virtual

Implements IShellFolder.

Definition at line 452 of file CRegFolder.cpp.

453 {
454  if (!pidl1 || !pidl2 || pidl1->mkid.cb == 0 || pidl2->mkid.cb == 0)
455  {
456  ERR("Got an empty pidl!\n");
457  return E_INVALIDARG;
458  }
459 
460  GUID const *clsid1 = _ILGetGUIDPointer (pidl1);
461  GUID const *clsid2 = _ILGetGUIDPointer (pidl2);
462 
463  if (!clsid1 && !clsid2)
464  {
465  ERR("Got no guid pidl!\n");
466  return E_INVALIDARG;
467  }
468  else if (clsid1 && clsid2)
469  {
470  if (memcmp(clsid1, clsid2, sizeof(GUID)) == 0)
471  return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
472 
473  return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
474  }
475 
476  /* Guid folders come first compared to everything else */
477  /* And Drives come before folders in My Computer */
479  {
480  return MAKE_COMPARE_HRESULT(clsid1 ? 1 : -1);
481  }
482  else
483  {
484  return MAKE_COMPARE_HRESULT(clsid1 ? -1 : 1);
485  }
486 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1920
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:546
HRESULT SHELL32_CompareChildren(IShellFolder2 *psf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:215
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT SHELL32_CompareDetails(IShellFolder2 *isf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:238
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
CComHeapPtr< ITEMIDLIST > m_pidlRoot
Definition: CRegFolder.cpp:285
#define ERR(fmt,...)
Definition: debug.h:110
LPARAM lParam
Definition: combotst.c:139

◆ CreateViewObject()

HRESULT WINAPI CRegFolder::CreateViewObject ( HWND  hwndOwner,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 488 of file CRegFolder.cpp.

489 {
490  return E_NOTIMPL;
491 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ EnumObjects()

HRESULT WINAPI CRegFolder::EnumObjects ( HWND  hwndOwner,
DWORD  dwFlags,
LPENUMIDLIST *  ppEnumIDList 
)
virtual

Definition at line 418 of file CRegFolder.cpp.

419 {
420  return ShellObjectCreatorInit<CRegFolderEnum>(m_enumKeyName, dwFlags, IID_PPV_ARG(IEnumIDList, ppEnumIDList));
421 }
#define IID_PPV_ARG(Itype, ppType)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
CAtlStringW m_enumKeyName
Definition: CRegFolder.cpp:284

◆ EnumSearches()

HRESULT WINAPI CRegFolder::EnumSearches ( IEnumExtraSearch **  ppenum)
virtual

Implements IShellFolder2.

Definition at line 710 of file CRegFolder.cpp.

711 {
712  return E_NOTIMPL;
713 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetAttributesOf()

HRESULT WINAPI CRegFolder::GetAttributesOf ( UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
DWORD rgfInOut 
)
virtual

Definition at line 493 of file CRegFolder.cpp.

494 {
495  if (!rgfInOut || !cidl || !apidl)
496  return E_INVALIDARG;
497 
498  if (*rgfInOut == 0)
499  *rgfInOut = ~0;
500 
501  while(cidl > 0 && *apidl)
502  {
503  if (_ILIsSpecialFolder(*apidl))
504  GetGuidItemAttributes(*apidl, rgfInOut);
505  else
506  ERR("Got an unkown pidl here!\n");
507  apidl++;
508  cidl--;
509  }
510 
511  /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
512  *rgfInOut &= ~SFGAO_VALIDATE;
513 
514  return S_OK;
515 }
static BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
HRESULT GetGuidItemAttributes(LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
Definition: CRegFolder.cpp:351
#define E_INVALIDARG
Definition: ddrawi.h:101
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52

◆ GetDefaultColumn()

HRESULT WINAPI CRegFolder::GetDefaultColumn ( DWORD  dwRes,
ULONG pSort,
ULONG pDisplay 
)
virtual

Implements IShellFolder2.

Definition at line 715 of file CRegFolder.cpp.

716 {
717  if (pSort)
718  *pSort = 0;
719  if (pDisplay)
720  *pDisplay = 0;
721 
722  return S_OK;
723 }
#define S_OK
Definition: intsafe.h:52

◆ GetDefaultColumnState()

HRESULT WINAPI CRegFolder::GetDefaultColumnState ( UINT  iColumn,
DWORD pcsFlags 
)
virtual

Implements IShellFolder2.

Definition at line 725 of file CRegFolder.cpp.

726 {
727  if (iColumn >= 2)
728  return E_INVALIDARG;
730  return S_OK;
731 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_OK
Definition: intsafe.h:52

◆ GetDefaultSearchGUID()

HRESULT WINAPI CRegFolder::GetDefaultSearchGUID ( GUID pguid)
virtual

Implements IShellFolder2.

Definition at line 705 of file CRegFolder.cpp.

706 {
707  return E_NOTIMPL;
708 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetDetailsEx()

HRESULT WINAPI CRegFolder::GetDetailsEx ( PCUITEMID_CHILD  pidl,
const SHCOLUMNID pscid,
VARIANT pv 
)
virtual

Implements IShellFolder2.

Definition at line 733 of file CRegFolder.cpp.

734 {
735  return E_NOTIMPL;
736 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetDetailsOf()

HRESULT WINAPI CRegFolder::GetDetailsOf ( PCUITEMID_CHILD  pidl,
UINT  iColumn,
SHELLDETAILS psd 
)
virtual

Implements IShellFolder2.

Definition at line 738 of file CRegFolder.cpp.

739 {
740  if (!psd)
741  return E_INVALIDARG;
742 
743  GUID const *clsid = _ILGetGUIDPointer (pidl);
744 
745  if (!clsid)
746  {
747  ERR("Pidl is not reg item!\n");
748  return E_INVALIDARG;
749  }
750 
751  if (iColumn >= 3)
752  {
753  /* Return an empty string when we area asked for a column we don't support.
754  Only the regfolder is supposed to do this as it supports less columns compared to other folder
755  and its contents are supposed to be presented alongside items that support more columns. */
756  return SHSetStrRet(&psd->str, "");
757  }
758 
759  switch(iColumn)
760  {
761  case 0: /* name */
762  return GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
763  case 1: /* comments */
764  HKEY hKey;
766  return SHSetStrRet(&psd->str, "");
767 
768  psd->str.cStr[0] = 0x00;
769  psd->str.uType = STRRET_CSTR;
770  RegLoadMUIStringA(hKey, "InfoTip", psd->str.cStr, MAX_PATH, NULL, 0, NULL);
771  RegCloseKey(hKey);
772  return S_OK;
773  case 2: /* type */
774  return SHSetStrRet(&psd->str, IDS_SYSTEMFOLDER);
775  }
776  return E_FAIL;
777 }
#define E_FAIL
Definition: ddrawi.h:102
STRRET str
Definition: shtypes.idl:108
char cStr[MAX_PATH]
Definition: shtypes.idl:98
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define E_INVALIDARG
Definition: ddrawi.h:101
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
#define MAX_PATH
Definition: compat.h:34
virtual HRESULT WINAPI GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)
Definition: CRegFolder.cpp:556
REFCLSID clsid
Definition: msctf.c:82
#define ERR(fmt,...)
Definition: debug.h:110
BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
Definition: classes.c:233
#define S_OK
Definition: intsafe.h:52
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
UINT uType
Definition: shtypes.idl:93
LONG WINAPI RegLoadMUIStringA(IN HKEY hKey, IN LPCSTR pszValue OPTIONAL, OUT LPSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCSTR pszDirectory OPTIONAL)
#define IDS_SYSTEMFOLDER
Definition: shresdef.h:321

◆ GetDisplayNameOf()

HRESULT WINAPI CRegFolder::GetDisplayNameOf ( PCUITEMID_CHILD  pidl,
DWORD  dwFlags,
LPSTRRET  strRet 
)
virtual

Definition at line 556 of file CRegFolder.cpp.

557 {
558  if (!strRet || (!_ILIsSpecialFolder(pidl) && pidl != NULL))
559  return E_INVALIDARG;
560 
561  if (!pidl || !pidl->mkid.cb)
562  {
564  {
565  LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
566  if (!pszPath)
567  return E_OUTOFMEMORY;
568 
569  /* parsing name like ::{...} */
570  pszPath[0] = ':';
571  pszPath[1] = ':';
572  SHELL32_GUIDToStringW(m_guid, &pszPath[2]);
573 
574  strRet->uType = STRRET_WSTR;
575  strRet->pOleStr = pszPath;
576 
577  return S_OK;
578  }
579  else
580  {
581  BOOL bRet;
582  WCHAR wstrName[MAX_PATH+1];
583  bRet = HCR_GetClassNameW(m_guid, wstrName, MAX_PATH);
584  if (!bRet)
585  return E_FAIL;
586 
587  return SHSetStrRet(strRet, wstrName);
588 
589  }
590  }
591 
592  HRESULT hr;
593  GUID const *clsid = _ILGetGUIDPointer (pidl);
594 
595  /* First of all check if we need to query the name from the child item */
598  {
599  int bWantsForParsing = FALSE;
600 
601  /*
602  * We can only get a filesystem path from a shellfolder if the
603  * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
604  *
605  * Exception: The MyComputer folder doesn't have this key,
606  * but any other filesystem backed folder it needs it.
607  */
608  if (IsEqualIID (*clsid, CLSID_MyComputer))
609  {
610  bWantsForParsing = TRUE;
611  }
612  else
613  {
614  HKEY hkeyClass;
615  if (HCR_RegOpenClassIDKey(*clsid, &hkeyClass))
616  {
617  LONG res = SHGetValueW(hkeyClass, L"Shellfolder", L"WantsForParsing", NULL, NULL, NULL);
618  bWantsForParsing = (res == ERROR_SUCCESS);
619  RegCloseKey(hkeyClass);
620  }
621  }
622 
623  if (bWantsForParsing)
624  {
625  /*
626  * we need the filesystem path to the destination folder.
627  * Only the folder itself can know it
628  */
629  return SHELL32_GetDisplayNameOfChild (this, pidl, dwFlags, strRet);
630  }
631  }
632 
633  /* Allocate the buffer for the result */
634  LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
635  if (!pszPath)
636  return E_OUTOFMEMORY;
637 
638  hr = S_OK;
639 
641  {
642  wcscpy(pszPath, m_rootPath);
643  PWCHAR pItemName = &pszPath[wcslen(pszPath)];
644 
645  /* parsing name like ::{...} */
646  pItemName[0] = ':';
647  pItemName[1] = ':';
648  SHELL32_GUIDToStringW (*clsid, &pItemName[2]);
649  }
650  else
651  {
652  /* user friendly name */
653  if (!HCR_GetClassNameW (*clsid, pszPath, MAX_PATH))
654  hr = E_FAIL;
655  }
656 
657  if (SUCCEEDED(hr))
658  {
659  strRet->uType = STRRET_WSTR;
660  strRet->pOleStr = pszPath;
661  }
662  else
663  {
664  CoTaskMemFree(pszPath);
665  }
666 
667  return hr;
668 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define GET_SHGDN_RELATION(dwFlags)
Definition: precomp.h:53
#define TRUE
Definition: types.h:120
LPWSTR pOleStr
Definition: shtypes.idl:96
uint16_t * PWCHAR
Definition: typedefs.h:56
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
static BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define GET_SHGDN_FOR(dwFlags)
Definition: precomp.h:52
if SUCCEEDED(hr)
CAtlStringW m_rootPath
Definition: CRegFolder.cpp:283
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT SHELL32_GetDisplayNameOfChild(IShellFolder2 *psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
Definition: shlfolder.cpp:197
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
#define MAX_PATH
Definition: compat.h:34
static __inline int SHELL32_GUIDToStringW(REFGUID guid, LPWSTR str)
Definition: shfldr.h:81
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
REFCLSID clsid
Definition: msctf.c:82
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
Definition: classes.c:233
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
UINT uType
Definition: shtypes.idl:93
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len)
Definition: classes.c:351

Referenced by GetDetailsOf().

◆ GetGuidItemAttributes()

HRESULT CRegFolder::GetGuidItemAttributes ( LPCITEMIDLIST  pidl,
LPDWORD  pdwAttributes 
)
private

Definition at line 351 of file CRegFolder.cpp.

352 {
353  DWORD dwAttributes = *pdwAttributes;
354 
355  /* First try to get them from the registry */
356  if (!HCR_GetFolderAttributes(pidl, pdwAttributes))
357  {
358  /* We couldn't get anything */
359  *pdwAttributes = 0;
360  }
361 
362  /* Items have more attributes when on desktop */
364  {
365  *pdwAttributes |= (dwAttributes & (SFGAO_CANLINK|SFGAO_CANDELETE|SFGAO_CANRENAME|SFGAO_HASPROPSHEET));
366  }
367 
368  /* In any case, links can be created */
369  if (*pdwAttributes == NULL)
370  {
371  *pdwAttributes |= (dwAttributes & SFGAO_CANLINK);
372  }
373  return S_OK;
374 }
DWORD dwAttributes
Definition: vdmdbg.h:34
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
unsigned long DWORD
Definition: ntddk_ex.h:95
CComHeapPtr< ITEMIDLIST > m_pidlRoot
Definition: CRegFolder.cpp:285
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD pdwAttributes)
Definition: classes.c:521

Referenced by GetAttributesOf(), and ParseDisplayName().

◆ GetUIObjectOf()

HRESULT WINAPI CRegFolder::GetUIObjectOf ( HWND  hwndOwner,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
REFIID  riid,
UINT prgfInOut,
LPVOID ppvOut 
)
virtual

Definition at line 517 of file CRegFolder.cpp.

519 {
520  LPVOID pObj = NULL;
522 
523  if (!ppvOut)
524  return hr;
525 
526  *ppvOut = NULL;
527 
528  if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
529  {
530  hr = CGuidItemExtractIcon_CreateInstance(apidl[0], riid, &pObj);
531  }
532  else if (IsEqualIID (riid, IID_IContextMenu) && (cidl >= 1))
533  {
534  if (!_ILGetGUIDPointer (apidl[0]))
535  {
536  ERR("Got non guid item!\n");
537  return E_FAIL;
538  }
539 
540  hr = CGuidItemContextMenu_CreateInstance(m_pidlRoot, hwndOwner, cidl, apidl, static_cast<IShellFolder*>(this), (IContextMenu**)&pObj);
541  }
542  else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
543  {
544  hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
545  }
546  else
547  {
548  hr = E_NOINTERFACE;
549  }
550 
551  *ppvOut = pObj;
552  return hr;
553 
554 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
REFIID riid
Definition: precomp.h:44
const GUID IID_IDataObject
#define E_FAIL
Definition: ddrawi.h:102
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject)
LONG HRESULT
Definition: typedefs.h:79
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
HRESULT CGuidItemContextMenu_CreateInstance(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, IContextMenu **ppcm)
Definition: CRegFolder.cpp:92
CComHeapPtr< ITEMIDLIST > m_pidlRoot
Definition: CRegFolder.cpp:285
HRESULT CGuidItemExtractIcon_CreateInstance(LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
Definition: CRegFolder.cpp:121
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ Initialize()

HRESULT WINAPI CRegFolder::Initialize ( const GUID pGuid,
LPCITEMIDLIST  pidlRoot,
LPCWSTR  lpszPath,
LPCWSTR  lpszEnumKeyName 
)

Definition at line 332 of file CRegFolder.cpp.

333 {
334  memcpy(&m_guid, pGuid, sizeof(m_guid));
335 
336  m_rootPath = lpszPath;
337  if (!m_rootPath)
338  return E_OUTOFMEMORY;
339 
340  m_enumKeyName = lpszEnumKeyName;
341  if (!m_enumKeyName)
342  return E_OUTOFMEMORY;
343 
344  m_pidlRoot.Attach(ILClone(pidlRoot));
345  if (!m_pidlRoot)
346  return E_OUTOFMEMORY;
347 
348  return S_OK;
349 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
CAtlStringW m_rootPath
Definition: CRegFolder.cpp:283
CComHeapPtr< ITEMIDLIST > m_pidlRoot
Definition: CRegFolder.cpp:285
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:52
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
CAtlStringW m_enumKeyName
Definition: CRegFolder.cpp:284

◆ MapColumnToSCID()

HRESULT WINAPI CRegFolder::MapColumnToSCID ( UINT  column,
SHCOLUMNID pscid 
)
virtual

Implements IShellFolder2.

Definition at line 779 of file CRegFolder.cpp.

780 {
781  return E_NOTIMPL;
782 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ParseDisplayName()

HRESULT WINAPI CRegFolder::ParseDisplayName ( HWND  hwndOwner,
LPBC  pbc,
LPOLESTR  lpszDisplayName,
ULONG pchEaten,
PIDLIST_RELATIVE ppidl,
ULONG pdwAttributes 
)
virtual

Implements IShellFolder.

Definition at line 376 of file CRegFolder.cpp.

378 {
379  LPITEMIDLIST pidl;
380 
381  if (!lpszDisplayName || !ppidl)
382  return E_INVALIDARG;
383 
384  *ppidl = 0;
385 
386  if (pchEaten)
387  *pchEaten = 0;
388 
389  UINT cch = wcslen(lpszDisplayName);
390  if (cch < 39 || lpszDisplayName[0] != L':' || lpszDisplayName[1] != L':')
391  return E_FAIL;
392 
393  pidl = _ILCreateGuidFromStrW(lpszDisplayName + 2);
394  if (pidl == NULL)
395  return E_FAIL;
396 
397  if (cch < 41)
398  {
399  *ppidl = pidl;
400  if (pdwAttributes && *pdwAttributes)
401  {
402  GetGuidItemAttributes(*ppidl, pdwAttributes);
403  }
404  }
405  else
406  {
407  HRESULT hr = SHELL32_ParseNextElement(this, hwndOwner, pbc, &pidl, lpszDisplayName + 41, pchEaten, pdwAttributes);
408  if (SUCCEEDED(hr))
409  {
410  *ppidl = pidl;
411  }
412  return hr;
413  }
414 
415  return S_OK;
416 }
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
HRESULT GetGuidItemAttributes(LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
Definition: CRegFolder.cpp:351
if SUCCEEDED(hr)
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT SHELL32_ParseNextElement(IShellFolder2 *psf, HWND hwndOwner, LPBC pbc, LPITEMIDLIST *pidlInOut, LPOLESTR szNext, DWORD *pEaten, DWORD *pdwAttributes)
Definition: shlfolder.cpp:70
LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID)
Definition: pidl.c:1725
LONG HRESULT
Definition: typedefs.h:79
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:52
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
IN PCTCH IN DWORD cch
Definition: pager.h:36
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

◆ SetNameOf()

HRESULT WINAPI CRegFolder::SetNameOf ( HWND  hwndOwner,
PCUITEMID_CHILD  pidl,
LPCOLESTR  lpName,
DWORD  dwFlags,
PITEMID_CHILD pPidlOut 
)
virtual

Implements IShellFolder.

Definition at line 670 of file CRegFolder.cpp.

672 {
673  GUID const *clsid = _ILGetGUIDPointer (pidl);
674  LPOLESTR pStr;
675  HRESULT hr;
676  WCHAR szName[100];
677 
678  if (!clsid)
679  {
680  ERR("Pidl is not reg item!\n");
681  return E_FAIL;
682  }
683 
684  hr = StringFromCLSID(*clsid, &pStr);
685  if (FAILED_UNEXPECTEDLY(hr))
686  return hr;
687 
688  swprintf(szName, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s", pStr);
689 
690  DWORD cbData = (wcslen(lpName) + 1) * sizeof(WCHAR);
692 
693  CoTaskMemFree(pStr);
694 
695  if (res == ERROR_SUCCESS)
696  {
697  *pPidlOut = ILClone(pidl);
698  return S_OK;
699  }
700 
701  return E_FAIL;
702 }
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_In_ LPCSTR lpName
Definition: winbase.h:2768
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define swprintf
Definition: precomp.h:40
static LPOLESTR
Definition: stg_prop.c:27
#define E_FAIL
Definition: ddrawi.h:102
long LONG
Definition: pedump.c:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
REFCLSID clsid
Definition: msctf.c:82
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static const WCHAR szName[]
Definition: msipriv.h:1194
GLuint res
Definition: glext.h:9613
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412

Member Data Documentation

◆ m_enumKeyName

CAtlStringW CRegFolder::m_enumKeyName
private

Definition at line 284 of file CRegFolder.cpp.

Referenced by EnumObjects(), and Initialize().

◆ m_guid

GUID CRegFolder::m_guid
private

Definition at line 282 of file CRegFolder.cpp.

Referenced by GetDisplayNameOf(), and Initialize().

◆ m_pidlRoot

CComHeapPtr<ITEMIDLIST> CRegFolder::m_pidlRoot
private

◆ m_rootPath

CAtlStringW CRegFolder::m_rootPath
private

Definition at line 283 of file CRegFolder.cpp.

Referenced by GetDisplayNameOf(), and Initialize().


The documentation for this class was generated from the following file: