ReactOS 0.4.16-dev-197-g92996da
shellfolderutils.h
Go to the documentation of this file.
1/*
2 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
3 * PURPOSE: Utility functions for IShellFolder implementations
4 * COPYRIGHT: Copyright 2024 Whindmar Saksit <whindsaks@proton.me>
5 */
6
7#pragma once
8
9#include "shellutils.h"
10
11#ifdef __cplusplus
12
13template <BOOL LOGICALCMP = TRUE>
14static HRESULT ShellFolderImpl_CompareItemColumn(IShellFolder2 *psf, UINT column, PCUITEMID_CHILD pidl1, PCUITEMID_CHILD pidl2)
15{
16 SHELLDETAILS details1, details2;
17 LPWSTR str1, str2;
18 HRESULT hr;
19 if (SUCCEEDED(hr = psf->GetDetailsOf(pidl1, column, &details1)) &&
20 SUCCEEDED(hr = StrRetToStrW(&details1.str, pidl1, &str1)))
21 {
22 if (SUCCEEDED(hr = psf->GetDetailsOf(pidl2, column, &details2)) &&
23 SUCCEEDED(hr = StrRetToStrW(&details2.str, pidl2, &str2)))
24 {
25 int res = LOGICALCMP ? StrCmpLogicalW(str1, str2) : lstrcmpiW(str1, str2);
27 SHFree(str2);
28 }
29 SHFree(str1);
30 }
31 return hr;
32}
33
34template <UINT COLCOUNT, int CANONICAL, BOOL LOGICALCMP = TRUE>
35static HRESULT ShellFolderImpl_CompareItemIDs(IShellFolder2 *psf, LPARAM lParam, PCUITEMID_CHILD pidl1, PCUITEMID_CHILD pidl2)
36{
37 HRESULT hr;
38 if (CANONICAL >= 0 && (lParam & SHCIDS_CANONICALONLY))
39 {
40 hr = ShellFolderImpl_CompareItemColumn<LOGICALCMP>(psf, CANONICAL, pidl1, pidl2);
41 if (hr == S_EQUAL || !(lParam & SHCIDS_ALLFIELDS) || FAILED(hr))
42 return hr;
43 }
45 {
46 for (UINT i = 0; i < COLCOUNT; ++i)
47 {
48 hr = ShellFolderImpl_CompareItemColumn<LOGICALCMP>(psf, i, pidl1, pidl2);
49 if (hr && SUCCEEDED(hr)) // Only stop if we successfully found a difference
50 break;
51 }
52 return hr;
53 }
54 const UINT column = (UINT)(lParam & SHCIDS_COLUMNMASK);
55 return ShellFolderImpl_CompareItemColumn<LOGICALCMP>(psf, column, pidl1, pidl2);
56}
57
58#endif // __cplusplus
#define SHCIDS_ALLFIELDS
Definition: CFontExt.cpp:15
LPARAM lParam
Definition: combotst.c:139
#define SHCIDS_CANONICALONLY
Definition: precomp.h:50
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
INT WINAPI StrCmpLogicalW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:2304
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1631
GLuint res
Definition: glext.h:9613
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HRESULT GetDetailsOf([in] PCUITEMID_CHILD pidl, [in] UINT iColumn, [out] SHELLDETAILS *psd)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:621
#define S_EQUAL
Definition: shellutils.h:619
HRESULT hr
Definition: shlfolder.c:183
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
STRRET str
Definition: shtypes.idl:108
LONG_PTR LPARAM
Definition: windef.h:208
WCHAR * LPWSTR
Definition: xmlstorage.h:184