ReactOS 0.4.17-dev-470-gf9e3448
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 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 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 686 of file shellutils.h.

◆ S_EQUAL

#define S_EQUAL   S_OK

Definition at line 684 of file shellutils.h.

◆ S_GREATERTHAN

#define S_GREATERTHAN   S_FALSE

Definition at line 685 of file shellutils.h.

◆ S_LESSTHAN

#define S_LESSTHAN   0xffff

Definition at line 683 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 910 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 913 of file shellutils.h.

914{
915 char buf[1024], *data, drive = 0;
916 for (UINT depth = 0, type; ; pidl = ILGetNext(pidl), ++depth)
917 {
918 if (!pidl || !pidl->mkid.cb)
919 {
920 if (!depth)
921 {
922 wsprintfA(buf, "%p [] (%s)\n", pidl, pidl ? "Empty/Desktop" : "NULL");
924 }
925 break;
926 }
927 else if (!depth)
928 {
929 wsprintfA(buf, "%p", pidl);
931 }
932 type = pidl->mkid.abID[0] & 0x7f;
933 data = (char*)&pidl->mkid.abID[0];
934 if (depth == 0 && type == 0x1f && pidl->mkid.cb == 20 && *(UINT*)(&data[2]) == 0x20D04FE0)
935 {
936 wsprintfA(buf, " [%.2x ThisPC?]", type); /* "?" because we did not check the full GUID */
937 }
938 else if (depth == 1 && type >= 0x20 && type < 0x30 && type != 0x2E && pidl->mkid.cb > 4)
939 {
940 drive = data[1];
941 wsprintfA(buf, " [%.2x %c: %ub]", type, drive, pidl->mkid.cb);
942 }
943 else if (depth >= 2 && drive && (type & 0x70) == 0x30) /* PT_FS */
944 {
945 if (type & 4)
946 wsprintfA(buf, " [%.2x FS %.256ls %ub]", type, data + 12, pidl->mkid.cb);
947 else
948 wsprintfA(buf, " [%.2x FS %.256hs %ub]", type, data + 12, pidl->mkid.cb);
949 }
950 else
951 {
952 wsprintfA(buf, " [%.2x ? %ub]", type, pidl->mkid.cb);
953 }
955 }
956 OutputDebugStringA("\n");
957}
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 721 of file shellutils.h.

722{
723 return (PCUIDLIST_RELATIVE)(((LPBYTE)pida) + (pida)->aoffset[i + 1]);
724}
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(), 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 711 of file shellutils.h.

712{
713 return pidl == ILFindLastID(pidl);
714}
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199

Referenced by CCabFolder::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
#define LoadStringW
Definition: utils.h:64
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
#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
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)

◆ SHELL_IsContextMenuMsg()

static BOOL SHELL_IsContextMenuMsg ( UINT  uMsg)
inlinestatic

Definition at line 705 of file shellutils.h.

706{
707 return uMsg == WM_MEASUREITEM || uMsg == WM_DRAWITEM ||
708 uMsg == WM_INITMENUPOPUP || uMsg == WM_MENUSELECT || uMsg == WM_MENUCHAR;
709}
#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().

◆ 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().