ReactOS 0.4.17-dev-1196-gb6224c3
shellutils.h File Reference

Go to the source code of this file.

Macros

#define DbgPrint(fmt, ...)    Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
 
#define IID_PPV_ARG(Itype, ppType)   &IID_##Itype, (void**)(ppType)
 
#define IID_NULL_PPV_ARG(Itype, ppType)   &IID_##Itype, NULL, (void**)(ppType)
 
#define FAILED_UNEXPECTEDLY(hr)   _ROS_FAILED_HELPER((hr), #hr, __FILE__, __LINE__)
 
#define SHELL_ErrorBox   SHELL_ErrorBoxHelper
 
#define S_LESSTHAN   0xffff
 
#define S_EQUAL   S_OK
 
#define S_GREATERTHAN   S_FALSE
 
#define MAKE_COMPARE_HRESULT(x)   ((x)>0 ? S_GREATERTHAN : ((x)<0 ? S_LESSTHAN : S_EQUAL))
 
#define SHELL_GetSetting(pss, ssf, field)   ( SHGetSetSettings((pss), (ssf), FALSE), (pss)->field )
 

Functions

static ULONG Win32DbgPrint (const char *filename, int line, const char *lpFormat,...)
 
static HRESULT HResultFromWin32 (DWORD hr)
 
static BOOL _ROS_FAILED_HELPER (HRESULT hr, const char *expr, const char *filename, int line)
 
static UINT SHELL_ErrorBoxHelper (HWND hwndOwner, UINT Error)
 
static HRESULT SHELL_RegGetStringEx (HKEY hKey, PCWSTR pszPath, PCWSTR pszName, UINT SRRF, PWSTR pszOut, DWORD cchMax)
 
static HRESULT SHELL_RegGetString (HKEY hKey, PCWSTR pszPath, PCWSTR pszName, PWSTR pszOut, DWORD cchMax)
 
static BOOL SHELL_IsContextMenuMsg (UINT uMsg)
 
static BOOL ILIsSingle (LPCITEMIDLIST pidl)
 
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder (CIDA const *pida)
 
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem (CIDA const *pida, SIZE_T i)
 
static SFGAOF SHELL_GetAttributesOf (IShellFolder *psf, LPCITEMIDLIST pidlChild, SFGAOF query)
 
static SFGAOF SHELL_GetAttributesOfAbsolute (PCIDLIST_ABSOLUTE pidl, SFGAOF query)
 
static void DumpIdListOneLine (LPCITEMIDLIST pidl)
 

Macro Definition Documentation

◆ DbgPrint

#define DbgPrint (   fmt,
  ... 
)     Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

Definition at line 59 of file shellutils.h.

◆ FAILED_UNEXPECTEDLY

#define FAILED_UNEXPECTEDLY (   hr)    _ROS_FAILED_HELPER((hr), #hr, __FILE__, __LINE__)

Definition at line 88 of file shellutils.h.

◆ IID_NULL_PPV_ARG

#define IID_NULL_PPV_ARG (   Itype,
  ppType 
)    &IID_##Itype, NULL, (void**)(ppType)

Definition at line 67 of file shellutils.h.

◆ IID_PPV_ARG

#define IID_PPV_ARG (   Itype,
  ppType 
)    &IID_##Itype, (void**)(ppType)

Definition at line 66 of file shellutils.h.

◆ MAKE_COMPARE_HRESULT

#define MAKE_COMPARE_HRESULT (   x)    ((x)>0 ? S_GREATERTHAN : ((x)<0 ? S_LESSTHAN : S_EQUAL))

Definition at line 740 of file shellutils.h.

◆ S_EQUAL

#define S_EQUAL   S_OK

Definition at line 738 of file shellutils.h.

◆ S_GREATERTHAN

#define S_GREATERTHAN   S_FALSE

Definition at line 739 of file shellutils.h.

◆ S_LESSTHAN

#define S_LESSTHAN   0xffff

Definition at line 737 of file shellutils.h.

◆ SHELL_ErrorBox

#define SHELL_ErrorBox   SHELL_ErrorBoxHelper

Definition at line 126 of file shellutils.h.

◆ SHELL_GetSetting

#define SHELL_GetSetting (   pss,
  ssf,
  field 
)    ( SHGetSetSettings((pss), (ssf), FALSE), (pss)->field )

Definition at line 1021 of file shellutils.h.

Function Documentation

◆ _ROS_FAILED_HELPER()

static BOOL _ROS_FAILED_HELPER ( HRESULT  hr,
const char *  expr,
const char *  filename,
int  line 
)
inlinestatic

Definition at line 78 of file shellutils.h.

79{
80 if (FAILED(hr))
81 {
82 Win32DbgPrint(filename, line, "Unexpected failure (%s)=%08x.\n", expr, hr);
83 return TRUE;
84 }
85 return FALSE;
86}
HRESULT hr
Definition: delayimp.cpp:582
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
static ULONG Win32DbgPrint(const char *filename, int line, const char *lpFormat,...)
Definition: shellutils.h:27
Definition: query.h:86
Definition: parser.c:49

◆ DumpIdListOneLine()

static void DumpIdListOneLine ( LPCITEMIDLIST  pidl)
inlinestatic

Definition at line 1024 of file shellutils.h.

1025{
1026 char buf[1024], *data, drive = 0;
1027 for (UINT depth = 0, type; ; pidl = ILGetNext(pidl), ++depth)
1028 {
1029 if (!pidl || !pidl->mkid.cb)
1030 {
1031 if (!depth)
1032 {
1033 wsprintfA(buf, "%p [] (%s)", pidl, pidl ? "Empty/Desktop" : "NULL");
1035 }
1036 break;
1037 }
1038 else if (!depth)
1039 {
1040 wsprintfA(buf, "%p", pidl);
1042 }
1043 type = pidl->mkid.abID[0] & 0x7f;
1044 data = (char*)&pidl->mkid.abID[0];
1045 if (depth == 0 && type == 0x1f && pidl->mkid.cb == 20 && *(UINT*)(&data[2]) == 0x20D04FE0)
1046 {
1047 wsprintfA(buf, " [%.2x ThisPC?]", type); /* "?" because we did not check the full GUID */
1048 }
1049 else if (depth == 1 && type >= 0x20 && type < 0x30 && type != 0x2E && pidl->mkid.cb > 4)
1050 {
1051 drive = data[1];
1052 wsprintfA(buf, " [%.2x %c: %ub]", type, drive, pidl->mkid.cb);
1053 }
1054 else if (depth >= 2 && drive && (type & 0x70) == 0x30) /* PT_FS */
1055 {
1056 if (type & 4)
1057 wsprintfA(buf, " [%.2x FS %.256ls %ub]", type, data + 12, pidl->mkid.cb);
1058 else
1059 wsprintfA(buf, " [%.2x FS %.256hs %ub]", type, data + 12, pidl->mkid.cb);
1060 }
1061 else
1062 {
1063 wsprintfA(buf, " [%.2x ? %ub]", type, pidl->mkid.cb);
1064 }
1066 }
1067 OutputDebugStringA("\n");
1068}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int UINT
Definition: sysinfo.c:13
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18
if(dx< 0)
Definition: linetemp.h:194
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:977
int WINAPIV wsprintfA(_Out_ LPSTR, _In_ _Printf_format_string_ LPCSTR,...)

◆ HIDA_GetPIDLFolder()

static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder ( CIDA const *  pida)
inlinestatic

◆ HIDA_GetPIDLItem()

static PCUIDLIST_RELATIVE HIDA_GetPIDLItem ( CIDA const *  pida,
SIZE_T  i 
)
inlinestatic

Definition at line 775 of file shellutils.h.

776{
777 return (PCUIDLIST_RELATIVE)(((LPBYTE)pida) + (pida)->aoffset[i + 1]);
778}
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
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57

Referenced by _ILCopyCidaToaPidl(), DeleteFontFiles(), CZipFolder::DeleteItems(), DoPreviewFontFiles(), CMyDocsDropHandler::Drop(), CDeskLinkDropHandler::Drop(), ExtractFilesCallback(), FSFolderItemPropDialogInitCallback(), CShellItemArray::GetItemAt(), COpenWithMenu::Initialize(), InstallFontsFromDataObject(), SHELL32_ShowFilesystemItemPropertiesDialogAsync(), SHELL_CIDA_ILCloneFull(), SHGetAttributesFromDataObject(), SHGetItemFromDataObject(), and TestHIDA().

◆ HResultFromWin32()

static HRESULT HResultFromWin32 ( DWORD  hr)
inlinestatic

Definition at line 70 of file shellutils.h.

71{
72 // HRESULT_FROM_WIN32 will evaluate its parameter twice, this function will not.
73 return HRESULT_FROM_WIN32(hr);
74}
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ ILIsSingle()

static BOOL ILIsSingle ( LPCITEMIDLIST  pidl)
inlinestatic

Definition at line 765 of file shellutils.h.

766{
767 return pidl == ILFindLastID(pidl);
768}
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199

Referenced by CCabFolder::CompareIDs(), CNetworkConnections::CompareIDs(), and SHOpenFolderAndSelectItems().

◆ SHELL_ErrorBoxHelper()

static UINT SHELL_ErrorBoxHelper ( HWND  hwndOwner,
UINT  Error 
)
inlinestatic

Definition at line 98 of file shellutils.h.

99{
100 WCHAR buf[400];
101 UINT cch;
102
103 if (!IsWindowVisible(hwndOwner))
104 hwndOwner = NULL;
105 if (Error == ERROR_SUCCESS)
107
109 NULL, Error, 0, buf, _countof(buf), NULL);
110 if (!cch)
111 {
112 enum { user32_IDS_ERROR = 2 }; // IDS_ERROR from user32 resource.h ("Error" string)
113 cch = LoadStringW(LoadLibraryW(L"USER32"), user32_IDS_ERROR, buf, _countof(buf));
114 wsprintfW(buf + cch, L"\n\n%#x (%d)", Error, Error);
115 }
116 MessageBoxW(hwndOwner, buf, NULL, MB_OK | MB_ICONSTOP);
117 return Error;
118}
BOOL Error
Definition: chkdsk.c:66
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define L(x)
Definition: resources.c:13
short WCHAR
Definition: pedump.c:58
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:801
#define MB_ICONSTOP
Definition: winuser.h:814
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define LoadStringW
Definition: utils.h:64
_In_ UINT _In_ UINT cch
Definition: shellapi.h:428
#define _countof(array)
Definition: sndvol32.h:70
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:397
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:1185

◆ SHELL_GetAttributesOf()

static SFGAOF SHELL_GetAttributesOf ( IShellFolder *  psf,
LPCITEMIDLIST  pidlChild,
SFGAOF  query 
)
inlinestatic

Definition at line 780 of file shellutils.h.

781{
782 SFGAOF attr = query;
783#ifdef __cplusplus
784 HRESULT hr = psf ? psf->GetAttributesOf(1, &pidlChild, &attr) : E_INVALIDARG;
785#else
786 HRESULT hr = psf ? psf->lpVtbl->GetAttributesOf(psf, 1, &pidlChild, &attr) : E_INVALIDARG;
787#endif
788 return SUCCEEDED(hr) ? (attr & query) : 0;
789}
#define E_INVALIDARG
Definition: ddrawi.h:101
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
HRESULT GetAttributesOf([in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in, out] SFGAOF *rgfInOut)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
Definition: cookie.c:202

Referenced by GetFolderItemBaseType(), SHELL_BrowseObject(), SHELL_GetAbsolutePidlTryLinkTarget(), and SHELL_GetAttributesOfAbsolute().

◆ SHELL_GetAttributesOfAbsolute()

static SFGAOF SHELL_GetAttributesOfAbsolute ( PCIDLIST_ABSOLUTE  pidl,
SFGAOF  query 
)
inlinestatic

Definition at line 791 of file shellutils.h.

792{
793 IShellFolder *psf;
794 PCUITEMID_CHILD pidlChild;
795 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlChild);
796 if (SUCCEEDED(hr))
797 {
798 SFGAOF attrib = SHELL_GetAttributesOf(psf, pidlChild, query);
799#ifdef __cplusplus
800 psf->Release();
801#else
802 psf->lpVtbl->Release(psf);
803#endif
804 return attrib;
805 }
806 return 0;
807}
ULONG Release()
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1504
#define IID_PPV_ARG(Itype, ppType)
Definition: shellutils.h:66
static SFGAOF SHELL_GetAttributesOf(IShellFolder *psf, LPCITEMIDLIST pidlChild, SFGAOF query)
Definition: shellutils.h:780
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70

◆ SHELL_IsContextMenuMsg()

static BOOL SHELL_IsContextMenuMsg ( UINT  uMsg)
inlinestatic

Definition at line 759 of file shellutils.h.

760{
761 return uMsg == WM_MEASUREITEM || uMsg == WM_DRAWITEM ||
762 uMsg == WM_INITMENUPOPUP || uMsg == WM_MENUSELECT || uMsg == WM_MENUCHAR;
763}
#define WM_DRAWITEM
Definition: winuser.h:1673
#define WM_MENUCHAR
Definition: winuser.h:1776
#define WM_INITMENUPOPUP
Definition: winuser.h:1774
#define WM_MEASUREITEM
Definition: winuser.h:1674
#define WM_MENUSELECT
Definition: winuser.h:1775

Referenced by BrFolderDlgProc(), and CDefaultContextMenu::HandleMenuMsg2().

◆ SHELL_RegGetString()

static HRESULT SHELL_RegGetString ( HKEY  hKey,
PCWSTR  pszPath,
PCWSTR  pszName,
PWSTR  pszOut,
DWORD  cchMax 
)
inlinestatic

Definition at line 141 of file shellutils.h.

142{
143 return SHELL_RegGetStringEx(hKey, pszPath, pszName, 1 << REG_SZ, pszOut, cchMax);
144}
UINT cchMax
#define REG_SZ
Definition: layer.c:22
FxAutoRegKey hKey
static HRESULT SHELL_RegGetStringEx(HKEY hKey, PCWSTR pszPath, PCWSTR pszName, UINT SRRF, PWSTR pszOut, DWORD cchMax)
Definition: shellutils.h:130

Referenced by GetClassKeyName(), and OpenClassKey().

◆ SHELL_RegGetStringEx()

static HRESULT SHELL_RegGetStringEx ( HKEY  hKey,
PCWSTR  pszPath,
PCWSTR  pszName,
UINT  SRRF,
PWSTR  pszOut,
DWORD  cchMax 
)
inlinestatic

Definition at line 130 of file shellutils.h.

131{
132#ifndef SRRF_RT_REG_SZ
134#endif
135 DWORD cb = cchMax * sizeof(*pszOut);
136 UINT err = SHRegGetValueW(hKey, pszPath, pszName, SRRF, NULL, pszOut, &cb);
137 return err ? HRESULT_FROM_WIN32(err) : (cb / sizeof(*pszOut));
138}
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLdouble n
Definition: glext.h:7729
GLfloat f
Definition: glext.h:7540
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define d
Definition: ke_i.h:81
INT SRRF
Definition: shlwapi.h:717
#define err(...)
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint32_t * LPDWORD
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
WINSHLWAPI LSTATUS WINAPI SHRegGetValueW(HKEY, LPCWSTR, LPCWSTR, SRRF, LPDWORD, LPVOID, LPDWORD)
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by SHELL_RegGetString().

◆ Win32DbgPrint()

static ULONG Win32DbgPrint ( const char *  filename,
int  line,
const char *  lpFormat,
  ... 
)
inlinestatic

Definition at line 27 of file shellutils.h.

28{
29 char szMsg[512];
30 char *szMsgStart;
31 const char *fname;
32 va_list vl;
33
34 fname = strrchr(filename, '\\');
35 if (fname == NULL)
36 {
37 fname = strrchr(filename, '/');
38 if (fname != NULL)
39 fname++;
40 }
41 else
42 fname++;
43
44 if (fname == NULL)
45 fname = filename;
46
47 szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
48
49 va_start(vl, lpFormat);
50 vsprintf(szMsgStart, lpFormat, vl);
51 va_end(vl);
52
53 OutputDebugStringA(szMsg);
54
55 /* Return STATUS_SUCCESS, since we are supposed to mimic DbgPrint */
56 return 0;
57}
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl vsprintf(char *, const char *, va_list) __WINE_CRT_PRINTF_ATTR(2
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3303
char * va_list
Definition: vadefs.h:50
#define sprintf
Definition: sprintf.c:45
LPCWSTR lpFormat
Definition: trayclock.cpp:32

Referenced by _ROS_FAILED_HELPER().