ReactOS 0.4.15-dev-8100-g1887773
utils.cpp File Reference
#include "precomp.h"
#include <shellapi.h>
#include <shlwapi.h>
#include <shlobj_undoc.h>
#include <shlguid_undoc.h>
#include <atlstr.h>
#include <shlwapi_undoc.h>
#include <strsafe.h>
Include dependency graph for utils.cpp:

Go to the source code of this file.

Macros

#define _ATL_NO_EXCEPTIONS
 
#define IShellFolder_GetDisplayNameOf   _disabled_IShellFolder_GetDisplayNameOf_
 
#define IShellFolder_ParseDisplayName   _disabled_IShellFolder_ParseDisplayName_
 
#define IShellFolder_CompareIDs   _disabled_IShellFolder_CompareIDs_
 
#define SHLWAPI_ISHELLFOLDER_HELPERS   /* HACK! */
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C BOOL WINAPI IContextMenu_Invoke (_In_ IContextMenu *pContextMenu, _In_ HWND hwnd, _In_ LPCSTR lpVerb, _In_ UINT uFlags)
 
BOOL WINAPI PathFileExistsDefExtAndAttributesW (_Inout_ LPWSTR pszPath, _In_ DWORD dwWhich, _Out_opt_ LPDWORD pdwFileAttributes)
 
static BOOL SHLWAPI_IsBogusHRESULT (HRESULT hr)
 
EXTERN_C HRESULT WINAPI IShellFolder_GetDisplayNameOf (_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD uFlags, _Out_ LPSTRRET lpName, _In_ DWORD dwRetryFlags)
 
EXTERN_C HRESULT WINAPI IShellFolder_ParseDisplayName (_In_ IShellFolder *psf, _In_opt_ HWND hwndOwner, _In_opt_ LPBC pbcReserved, _In_ LPOLESTR lpszDisplayName, _Out_opt_ ULONG *pchEaten, _Out_opt_ PIDLIST_RELATIVE *ppidl, _Out_opt_ ULONG *pdwAttributes)
 
EXTERN_C HRESULT WINAPI IShellFolder_CompareIDs (_In_ IShellFolder *psf, _In_ LPARAM lParam, _In_ PCUIDLIST_RELATIVE pidl1, _In_ PCUIDLIST_RELATIVE pidl2)
 

Macro Definition Documentation

◆ _ATL_NO_EXCEPTIONS

#define _ATL_NO_EXCEPTIONS

Definition at line 8 of file utils.cpp.

◆ IShellFolder_CompareIDs

#define IShellFolder_CompareIDs   _disabled_IShellFolder_CompareIDs_

Definition at line 15 of file utils.cpp.

◆ IShellFolder_GetDisplayNameOf

#define IShellFolder_GetDisplayNameOf   _disabled_IShellFolder_GetDisplayNameOf_

Definition at line 13 of file utils.cpp.

◆ IShellFolder_ParseDisplayName

#define IShellFolder_ParseDisplayName   _disabled_IShellFolder_ParseDisplayName_

Definition at line 14 of file utils.cpp.

◆ SHLWAPI_ISHELLFOLDER_HELPERS

#define SHLWAPI_ISHELLFOLDER_HELPERS   /* HACK! */

Definition at line 31 of file utils.cpp.

Function Documentation

◆ IContextMenu_Invoke()

EXTERN_C BOOL WINAPI IContextMenu_Invoke ( _In_ IContextMenu pContextMenu,
_In_ HWND  hwnd,
_In_ LPCSTR  lpVerb,
_In_ UINT  uFlags 
)

Definition at line 45 of file utils.cpp.

50{
51 CMINVOKECOMMANDINFO info;
52 BOOL ret = FALSE;
53 INT iDefItem = 0;
54 HMENU hMenu = NULL;
55 HCURSOR hOldCursor;
56
57 TRACE("(%p, %p, %s, %u)\n", pContextMenu, hwnd, debugstr_a(lpVerb), uFlags);
58
59 if (!pContextMenu)
60 return FALSE;
61
62 hOldCursor = SetCursor(LoadCursorW(NULL, (LPCWSTR)IDC_WAIT));
63
64 ZeroMemory(&info, sizeof(info));
65 info.cbSize = sizeof(info);
66 info.hwnd = hwnd;
67 info.nShow = SW_NORMAL;
68 info.lpVerb = lpVerb;
69
70 if (IS_INTRESOURCE(lpVerb))
71 {
72 hMenu = CreatePopupMenu();
73 if (hMenu)
74 {
75 pContextMenu->QueryContextMenu(hMenu, 0, 1, MAXSHORT, uFlags | CMF_DEFAULTONLY);
76 iDefItem = GetMenuDefaultItem(hMenu, 0, 0);
77 if (iDefItem != -1)
78 info.lpVerb = MAKEINTRESOURCEA(iDefItem - 1);
79 }
80 }
81
82 if (iDefItem != -1 || info.lpVerb)
83 {
84 if (!hwnd)
85 info.fMask |= CMIC_MASK_FLAG_NO_UI;
86 ret = SUCCEEDED(pContextMenu->InvokeCommand(&info));
87 }
88
89 /* Invoking itself doesn't need the menu object, but getting the command info
90 needs the menu. */
91 if (hMenu)
92 DestroyMenu(hMenu);
93
94 SetCursor(hOldCursor);
95
96 return ret;
97}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
UINT uFlags
Definition: api.c:59
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_a
Definition: kernel32.h:31
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT
Definition: typedefs.h:58
#define MAXSHORT
Definition: umtypes.h:114
int ret
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HICON HCURSOR
Definition: windef.h:299
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define IDC_WAIT
Definition: winuser.h:689
#define SW_NORMAL
Definition: winuser.h:769
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ IShellFolder_CompareIDs()

EXTERN_C HRESULT WINAPI IShellFolder_CompareIDs ( _In_ IShellFolder psf,
_In_ LPARAM  lParam,
_In_ PCUIDLIST_RELATIVE  pidl1,
_In_ PCUIDLIST_RELATIVE  pidl2 
)

Definition at line 214 of file utils.cpp.

219{
220 TRACE("(%p, %p, %p, %p)\n", psf, lParam, pidl1, pidl2);
221
222 if (lParam & ~(SIZE_T)SHCIDS_COLUMNMASK)
223 {
224 /* Try as IShellFolder2 if possible */
225 HRESULT hr = psf->QueryInterface(IID_IShellFolder2, (void **)&psf);
226 if (FAILED(hr))
227 lParam &= SHCIDS_COLUMNMASK;
228 else
229 psf->Release();
230 }
231
232 return psf->CompareIDs(lParam, pidl1, pidl2);
233}
LPARAM lParam
Definition: combotst.c:139
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
nsrefcnt Release()
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
ULONG_PTR SIZE_T
Definition: typedefs.h:80

◆ IShellFolder_GetDisplayNameOf()

EXTERN_C HRESULT WINAPI IShellFolder_GetDisplayNameOf ( _In_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ DWORD  uFlags,
_Out_ LPSTRRET  lpName,
_In_ DWORD  dwRetryFlags 
)

Definition at line 147 of file utils.cpp.

153{
154 HRESULT hr;
155
156 TRACE("(%p)->(%p, 0x%lX, %p, 0x%lX)\n", psf, pidl, uFlags, lpName, dwRetryFlags);
157
158 hr = psf->GetDisplayNameOf(pidl, uFlags, lpName);
160 return hr;
161
162 dwRetryFlags |= 0x80000000;
163
164 if ((uFlags & SHGDN_FORPARSING) == 0)
165 dwRetryFlags |= SFGDNO_RETRYWITHFORPARSING;
166
167 /* It seems the function is actually retrying here */
168 FIXME("dwRetryFlags: 0x%X\n", dwRetryFlags);
169
170 return hr;
171}
#define FIXME(fmt,...)
Definition: debug.h:114
static BOOL SHLWAPI_IsBogusHRESULT(HRESULT hr)
Definition: utils.cpp:138
_In_ LPCSTR lpName
Definition: winbase.h:2789

◆ IShellFolder_ParseDisplayName()

EXTERN_C HRESULT WINAPI IShellFolder_ParseDisplayName ( _In_ IShellFolder psf,
_In_opt_ HWND  hwndOwner,
_In_opt_ LPBC  pbcReserved,
_In_ LPOLESTR  lpszDisplayName,
_Out_opt_ ULONG pchEaten,
_Out_opt_ PIDLIST_RELATIVE ppidl,
_Out_opt_ ULONG pdwAttributes 
)

Definition at line 177 of file utils.cpp.

185{
186 ULONG dummy1, dummy2;
187
188 TRACE("(%p)->(%p, %p, %s, %p, %p, %p)\n", psf, hwndOwner, pbcReserved,
189 debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
190
191 if (!pdwAttributes)
192 {
193 dummy1 = 0;
194 pdwAttributes = &dummy1;
195 }
196
197 if (!pchEaten)
198 {
199 dummy2 = 0;
200 pchEaten = &dummy2;
201 }
202
203 if (ppidl)
204 *ppidl = NULL;
205
206 return psf->ParseDisplayName(hwndOwner, pbcReserved, lpszDisplayName, pchEaten,
207 ppidl, pdwAttributes);
208}
#define debugstr_w
Definition: kernel32.h:32
uint32_t ULONG
Definition: typedefs.h:59

◆ PathFileExistsDefExtAndAttributesW()

BOOL WINAPI PathFileExistsDefExtAndAttributesW ( _Inout_ LPWSTR  pszPath,
_In_ DWORD  dwWhich,
_Out_opt_ LPDWORD  pdwFileAttributes 
)

Definition at line 108 of file utils.cpp.

112{
113 TRACE("(%s, 0x%lX, %p)\n", debugstr_w(pszPath), dwWhich, pdwFileAttributes);
114
115 if (pdwFileAttributes)
116 *pdwFileAttributes = INVALID_FILE_ATTRIBUTES;
117
118 if (!pszPath)
119 return FALSE;
120
121 if (!dwWhich || (*PathFindExtensionW(pszPath) && (dwWhich & WHICH_OPTIONAL)))
122 return PathFileExistsAndAttributesW(pszPath, pdwFileAttributes);
123
124 if (!PathFileExistsDefExtW(pszPath, dwWhich))
125 {
126 if (pdwFileAttributes)
127 *pdwFileAttributes = INVALID_FILE_ATTRIBUTES;
128 return FALSE;
129 }
130
131 if (pdwFileAttributes)
132 *pdwFileAttributes = GetFileAttributesW(pszPath);
133
134 return TRUE;
135}
#define TRUE
Definition: types.h:120
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr)
Definition: path.c:1832
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1117
#define WHICH_OPTIONAL
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by START_TEST().

◆ SHLWAPI_IsBogusHRESULT()

static BOOL SHLWAPI_IsBogusHRESULT ( HRESULT  hr)
inlinestatic

Definition at line 138 of file utils.cpp.

139{
140 return (hr == E_FAIL || hr == E_INVALIDARG || hr == E_NOTIMPL);
141}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102

Referenced by IShellFolder_GetDisplayNameOf().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )