ReactOS 0.4.17-dev-116-ga4b6fe9
utils.cpp File Reference
#include "precomp.h"
#include <lmcons.h>
#include <lmapibuf.h>
#include <lmaccess.h>
#include <lmserver.h>
#include <secext.h>
Include dependency graph for utils.cpp:

Go to the source code of this file.

Classes

class  CDummyOleWindow
 
struct  tagALIAS_MAPPING
 

Macros

#define PATH_VALID_ELEMENT
 
#define COPY_STREAM_DEFAULT_BUFFER_SIZE   0x4000
 
#define COMPUTER_DESCRIPTIONS_KEY    L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComputerDescriptions"
 

Typedefs

typedef struct tagALIAS_MAPPING ALIAS_MAPPING
 
typedef struct tagALIAS_MAPPINGPALIAS_MAPPING
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static PCSTR StrEndNA (_In_ PCSTR psz, _In_ INT_PTR cch)
 
static PCWSTR StrEndNW (_In_ PCWSTR psz, _In_ INT_PTR cch)
 
static INT _SHMergePopupMenus (HMENU hMenu, HMENU hPopupMenu, UINT uIDAdjust, UINT uIDAdjustMax)
 
static HMENU SHLoadPopupMenu (HINSTANCE hInstance, UINT uMenuId)
 
EXTERN_C VOID WINAPI CDefFolderMenu_MergeMenu (_In_ HINSTANCE hInstance, _In_ UINT uMainMerge, _In_ UINT uPopupMerge, _Inout_ LPQCMINFO lpQcmInfo)
 
EXTERN_C PSTR WINAPI StrRStrA (_In_ PCSTR pszSrc, _In_opt_ PCSTR pszLast, _In_ PCSTR pszSearch)
 
EXTERN_C PWSTR WINAPI StrRStrW (_In_ PCWSTR pszSrc, _In_opt_ PCWSTR pszLast, _In_ PCWSTR pszSearch)
 
HRESULT SHILClone (_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
 
BOOL PathIsDotOrDotDotW (_In_ LPCWSTR pszPath)
 
BOOL PathIsValidElement (_In_ LPCWSTR pszPath)
 
BOOL PathIsDosDevice (_In_ LPCWSTR pszName)
 
HRESULT SHILAppend (_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl)
 
EXTERN_C HRESULT WINAPI SHShouldShowWizards (_In_ IUnknown *pUnknown)
 
static BOOL OpenEffectiveToken (_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
 
BOOL BindCtx_ContainsObject (_In_ IBindCtx *pBindCtx, _In_ LPCWSTR pszName)
 
DWORD BindCtx_GetMode (_In_ IBindCtx *pbc, _In_ DWORD dwDefault)
 
BOOL SHSkipJunctionBinding (_In_ IBindCtx *pbc, _In_ CLSID *pclsid)
 
HRESULT SHIsFileSysBindCtx (_In_ IBindCtx *pBindCtx, _Out_opt_ WIN32_FIND_DATAW *pFindData)
 
BOOL Shell_FailForceReturn (_In_ HRESULT hr)
 
HRESULT SHBindToObjectEx (_In_opt_ IShellFolder *pShellFolder, _In_ LPCITEMIDLIST pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj)
 
EXTERN_C HRESULT SHBindToObject (_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
 
EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem (_In_opt_ HWND hWnd, _In_ PCIDLIST_ABSOLUTE pidl, _In_ REFIID riid, _Out_ void **ppvObj)
 
HRESULT SHELL_DisplayNameOf (_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_opt_ UINT Flags, _Out_ PWSTR *ppStr)
 
EXTERN_C HRESULT WINAPI DisplayNameOfW (_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
 
DWORD SHGetAttributes (_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
 
HRESULT SHELL_GetIDListTarget (_In_ LPCITEMIDLIST pidl, _Out_ PIDLIST_ABSOLUTE *ppidl)
 
HRESULT SHCoInitializeAnyApartment (VOID)
 
HRESULT SHGetNameAndFlagsW (_In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_opt_ LPWSTR pszText, _In_ UINT cchBuf, _Inout_opt_ DWORD *pdwAttributes)
 
EXTERN_C HWND BindCtx_GetUIWindow (_In_ IBindCtx *pBindCtx)
 
EXTERN_C HRESULT BindCtx_RegisterObjectParam (_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
 
EXTERN_C HRESULT WINAPI SHSetFolderPathA (_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCSTR pszPath)
 
EXTERN_C BOOL WINAPI PathIsSlowA (_In_ LPCSTR pszFile, _In_ DWORD dwAttr)
 
EXTERN_C WORD WINAPI ExtractIconResInfoA (_In_ HANDLE hHandle, _In_ LPCSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
 
EXTERN_C LPWSTR WINAPI ShortSizeFormatW (_In_ DWORD dwNumber, _Out_writes_(0x8FFF) LPWSTR pszBuffer)
 
EXTERN_C BOOL WINAPI SHOpenEffectiveToken (_Out_ LPHANDLE phToken)
 
EXTERN_C DWORD WINAPI SHGetUserSessionId (_In_opt_ HANDLE hToken)
 
EXTERN_C HRESULT WINAPI SHInvokePrivilegedFunctionW (_In_ LPCWSTR pszName, _In_ PRIVILEGED_FUNCTION fn, _In_opt_ LPARAM lParam)
 
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW (_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
 
BOOL IsShutdownAllowed (VOID)
 
BOOL WINAPI IsSuspendAllowed (VOID)
 
EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance (VOID)
 
EXTERN_C HRESULT WINAPI SHCreatePropertyBag (_In_ REFIID riid, _Out_ void **ppvObj)
 
static DWORD SHELL_ReadSingleUnreadMailCount (_In_ HKEY hKey, _Out_opt_ PDWORD pdwCount, _Out_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) LPWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
 
EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW (_In_opt_ HKEY hKeyUser, _In_opt_ PCWSTR pszMailAddress, _Out_opt_ PDWORD pdwCount, _Inout_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) PWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
 
EXTERN_C HRESULT WINAPI SHSetUnreadMailCountW (_In_ PCWSTR pszMailAddress, _In_ DWORD dwCount, _In_ PCWSTR pszShellExecuteCommand)
 
EXTERN_C LPSTR WINAPI SheRemoveQuotesA (LPSTR psz)
 
EXTERN_C LPWSTR WINAPI SheRemoveQuotesW (LPWSTR psz)
 
EXTERN_C HRESULT WINAPI SHEnumerateUnreadMailAccountsW (_In_opt_ HKEY hKeyUser, _In_ DWORD dwIndex, _Out_writes_(cchMailAddress) PWSTR pszMailAddress, _In_ INT cchMailAddress)
 
EXTERN_C BOOL WINAPI SHFindComputer (LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch)
 
static HRESULT Int64ToStr (_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
 
static VOID Int64GetNumFormat (_Out_ NUMBERFMTW *pDest, _In_opt_ const NUMBERFMTW *pSrc, _In_ DWORD dwNumberFlags, _Out_writes_(cchDecimal) LPWSTR pszDecimal, _In_ INT cchDecimal, _Out_writes_(cchThousand) LPWSTR pszThousand, _In_ INT cchThousand)
 
EXTERN_C INT WINAPI Int64ToString (_In_ LONGLONG llValue, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
 
EXTERN_C INT WINAPI LargeIntegerToString (_In_ const LARGE_INTEGER *pLargeInt, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
 
EXTERN_C HRESULT WINAPI CopyStreamUI (_In_ IStream *pSrc, _Out_ IStream *pDst, _Inout_opt_ IProgressDialog *pProgress, _In_opt_ DWORDLONG dwlSize)
 
EXTERN_C BOOL WINAPI Activate_RunDLL (_In_ HWND hwnd, _In_ HINSTANCE hinst, _In_ LPCWSTR cmdline, _In_ INT cmdshow)
 
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogA (_In_ HWND hwnd, _In_ LPCSTR pszRemoteName, _In_ DWORD dwType)
 
static INT DynamicPathCommonPrefixW (_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
 
EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW (LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax)
 
static HRESULT DynamicSHGetPathFromIDListW (_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
 
static HRESULT DynamicSHGetSpecialFolderPathW (_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
 
static VOID DynamicPathRemoveBackslashW (_Out_ CStringW &strPath)
 
EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder (_In_ LPCWSTR pszPath1OrCSIDL, _In_ LPCWSTR pszPath2)
 
EXTERN_C HRESULT WINAPI SHGetRealIDL (_In_ IShellFolder *psf, _In_ PCUITEMID_CHILD pidlSimple, _Outptr_ PITEMID_CHILD *ppidlReal)
 
EXTERN_C HRESULT IUnknown_InitializeCommand (_In_ IUnknown *pUnk, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB)
 
EXTERN_C HRESULT InvokeIExecuteCommand (_In_ IExecuteCommand *pEC, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB, _In_opt_ IShellItemArray *pSIA, _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, _In_opt_ IUnknown *pSite)
 
EXTERN_C HRESULT InvokeIExecuteCommandWithDataObject (_In_ IExecuteCommand *pEC, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB, _In_ IDataObject *pDO, _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, _In_opt_ IUnknown *pSite)
 
static HRESULT GetCommandStringA (_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
 
UINT GetDfmCmd (_In_ IContextMenu *pCM, _In_ LPCSTR verba)
 
HRESULT SHELL_MapContextMenuVerbToCmdId (LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
 
static const CMVERBMAPFindVerbMapEntry (UINT_PTR CmdId, const CMVERBMAP *pMap)
 
HRESULT SHELL_GetCommandStringImpl (SIZE_T CmdId, UINT uFlags, LPSTR Buf, UINT cchBuf, const CMVERBMAP *pMap)
 
HRESULT SHELL_CreateShell32DefaultExtractIcon (int IconIndex, REFIID riid, LPVOID *ppvOut)
 
int DCIA_AddEntry (HDCIA hDCIA, REFCLSID rClsId)
 
void DCIA_AddShellExSubkey (HDCIA hDCIA, HKEY hProgId, PCWSTR pszSubkey)
 
EXTERN_C BOOL WINAPI SHIsBadInterfacePtr (_In_ LPCVOID pv, _In_ UINT_PTR ucb)
 
EXTERN_C HRESULT WINAPI SHGetUserDisplayName (_Out_writes_to_(*puSize, *puSize) PWSTR pName, _Inout_ PULONG puSize)
 
static PCWSTR SHELL_SkipServerSlashes (_In_ PCWSTR pszPath)
 
static HRESULT SHELL_GetCachedComputerDescription (_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ DWORD cchDescMax, _In_ PCWSTR pszServerName)
 
static VOID SHELL_CacheComputerDescription (_In_ PCWSTR pszServerName, _In_ PCWSTR pszDesc)
 
static HRESULT SHELL_GetComputerDescription (_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ SIZE_T cchDescMax, _In_ PWSTR pszServerName)
 
static HRESULT SHELL_BuildDisplayMachineName (_Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax, _In_ PCWSTR pszServerName, _In_ PCWSTR pszDescription)
 
EXTERN_C HRESULT WINAPI SHGetComputerDisplayNameW (_In_opt_ PWSTR pszServerName, _In_ DWORD dwFlags, _Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax)
 
EXTERN_C BOOL SHELL32_ReparentAsAliasPidl (_In_opt_ HWND hwnd, _In_opt_ HANDLE hToken, _In_ LPCITEMIDLIST pidlTarget, _Out_ LPITEMIDLIST *ppidlNew, _In_ DWORD dwFlags)
 Translate a PIDL to an "alias" PIDL.
 
EXTERN_C HRESULT WINAPI SHSetLocalizedName (_In_ PCWSTR pszPath, _In_ PCWSTR pszResModule, _In_ INT idsRes)
 
EXTERN_C HRESULT SHELL32_AliasTranslatePidl (_In_ LPCITEMIDLIST pidl, _Out_ LPITEMIDLIST *ppidlNew, _In_ DWORD dwFlags)
 Translate a PIDL to an "alias" PIDL.
 
EXTERN_C BOOL WINAPI LinkWindow_RegisterClass (VOID)
 
EXTERN_C BOOL WINAPI LinkWindow_UnregisterClass (_In_ DWORD dwUnused)
 

Variables

static const ALIAS_MAPPING g_AliasTable []
 PIDL alias table.
 

Macro Definition Documentation

◆ COMPUTER_DESCRIPTIONS_KEY

#define COMPUTER_DESCRIPTIONS_KEY    L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComputerDescriptions"

Definition at line 2033 of file utils.cpp.

◆ COPY_STREAM_DEFAULT_BUFFER_SIZE

#define COPY_STREAM_DEFAULT_BUFFER_SIZE   0x4000

◆ PATH_VALID_ELEMENT

#define PATH_VALID_ELEMENT
Value:
( \
)
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:2139
#define PATH_CHAR_CLASS_SPACE
Definition: path.c:2138
#define PATH_CHAR_CLASS_SEMICOLON
Definition: path.c:2136
#define PATH_CHAR_CLASS_COMMA
Definition: path.c:2137
#define PATH_CHAR_CLASS_DOT
Definition: path.c:2133

Definition at line 235 of file utils.cpp.

Typedef Documentation

◆ ALIAS_MAPPING

◆ PALIAS_MAPPING

Function Documentation

◆ _SHMergePopupMenus()

static INT _SHMergePopupMenus ( HMENU  hMenu,
HMENU  hPopupMenu,
UINT  uIDAdjust,
UINT  uIDAdjustMax 
)
static

Definition at line 35 of file utils.cpp.

36{
37 INT maxID = uIDAdjust;
38 const INT itemCount = GetMenuItemCount(hPopupMenu);
39 if (itemCount == -1)
40 return maxID;
41
42 MENUITEMINFOW mii = { sizeof(mii), MIIM_ID | MIIM_SUBMENU };
43 for (INT i = itemCount - 1; i >= 0; --i)
44 {
45 if (!GetMenuItemInfoW(hPopupMenu, i, TRUE, &mii))
46 continue;
47
48 HMENU hTargetSubMenu = SHGetMenuFromID(hMenu, mii.wID);
49 if (!hTargetSubMenu)
50 continue;
51
52 INT currentMax = Shell_MergeMenus(hTargetSubMenu, mii.hSubMenu, 0,
53 uIDAdjust, uIDAdjustMax,
55 maxID = max(maxID, currentMax);
56 }
57
58 return maxID;
59}
#define TRUE
Definition: types.h:120
HMENU WINAPI SHGetMenuFromID(HMENU hMenu, UINT uID)
Definition: ordinal.c:1997
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
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:856
#define MM_SUBMENUSHAVEIDS
Definition: shlobj.h:2537
#define MM_ADDSEPARATOR
Definition: shlobj.h:2536
#define max(a, b)
Definition: svc.c:63
int32_t INT
Definition: typedefs.h:58
#define MIIM_ID
Definition: winuser.h:733
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define MIIM_SUBMENU
Definition: winuser.h:734
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)

Referenced by CDefFolderMenu_MergeMenu().

◆ Activate_RunDLL()

EXTERN_C BOOL WINAPI Activate_RunDLL ( _In_ HWND  hwnd,
_In_ HINSTANCE  hinst,
_In_ LPCWSTR  cmdline,
_In_ INT  cmdshow 
)

Definition at line 1549 of file utils.cpp.

1554{
1555 DWORD dwProcessID;
1556
1560 UNREFERENCED_PARAMETER(cmdshow);
1561
1562 TRACE("(%p, %p, %s, %d)\n", hwnd, hinst, debugstr_w(cmdline), cmdline);
1563
1565 return AllowSetForegroundWindow(dwProcessID);
1566}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define debugstr_w
Definition: kernel32.h:32
static HINSTANCE hinst
Definition: edit.c:551
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define TRACE(s)
Definition: solgame.cpp:4
TCHAR * cmdline
Definition: stretchblt.cpp:32
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
HWND WINAPI GetShellWindow(void)
Definition: input.c:974
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ BindCtx_ContainsObject()

BOOL BindCtx_ContainsObject ( _In_ IBindCtx pBindCtx,
_In_ LPCWSTR  pszName 
)

Definition at line 342 of file utils.cpp.

343{
345 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
346 return FALSE;
347 return TRUE;
348}
#define FALSE
Definition: types.h:117
#define FAILED(hr)
Definition: intsafe.h:51
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by CDesktopFolder::_ParseDisplayNameByParent(), CDesktopFolder::ParseDisplayName(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ BindCtx_GetMode()

DWORD BindCtx_GetMode ( _In_ IBindCtx pbc,
_In_ DWORD  dwDefault 
)

Definition at line 350 of file utils.cpp.

351{
352 if (!pbc)
353 return dwDefault;
354
355 BIND_OPTS BindOpts = { sizeof(BindOpts) };
356 HRESULT hr = pbc->GetBindOptions(&BindOpts);
357 if (FAILED(hr))
358 return dwDefault;
359
360 return BindOpts.grfMode;
361}
HRESULT hr
Definition: delayimp.cpp:573

Referenced by CDrivesFolder::ParseDisplayName(), CFSFolder::ParseDisplayName(), and CRegFolder::ParseDisplayName().

◆ BindCtx_GetUIWindow()

EXTERN_C HWND BindCtx_GetUIWindow ( _In_ IBindCtx pBindCtx)

Definition at line 609 of file utils.cpp.

610{
611 HWND hWnd = NULL;
612
614 if (pBindCtx && SUCCEEDED(pBindCtx->GetObjectParam((LPWSTR)L"UI During Binding", &punk)))
616
617 return hWnd;
618}
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1336
#define L(x)
Definition: resources.c:13
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by SHParseDisplayName().

◆ BindCtx_RegisterObjectParam()

EXTERN_C HRESULT BindCtx_RegisterObjectParam ( _In_ IBindCtx pBindCtx,
_In_ LPOLESTR  pszKey,
_In_opt_ IUnknown punk,
_Out_ LPBC ppbc 
)

Definition at line 669 of file utils.cpp.

674{
675 HRESULT hr = S_OK;
677
678 *ppbc = pBindCtx;
679
680 if (pBindCtx)
681 {
682 pBindCtx->AddRef();
683 }
684 else
685 {
686 hr = CreateBindCtx(0, ppbc);
687 if (FAILED(hr))
688 return hr;
689 }
690
691 if (!punk)
692 punk = pUnknown = new CDummyOleWindow();
693
694 hr = (*ppbc)->RegisterObjectParam(pszKey, punk);
695
696 if (pUnknown)
697 pUnknown->Release();
698
699 if (FAILED(hr))
700 {
701 (*ppbc)->Release();
702 *ppbc = NULL;
703 }
704
705 return hr;
706}
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
ULONG Release()
#define S_OK
Definition: intsafe.h:52
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
Definition: bindctx.c:491

Referenced by SHParseDisplayName().

◆ CDefFolderMenu_MergeMenu()

EXTERN_C VOID WINAPI CDefFolderMenu_MergeMenu ( _In_ HINSTANCE  hInstance,
_In_ UINT  uMainMerge,
_In_ UINT  uPopupMerge,
_Inout_ LPQCMINFO  lpQcmInfo 
)

Definition at line 77 of file utils.cpp.

82{
83 UINT idCmdFirst = lpQcmInfo->idCmdFirst;
84 HMENU hPopupMenu;
85
86 if (uMainMerge)
87 {
88 hPopupMenu = SHLoadPopupMenu(hInstance, uMainMerge);
89 if (hPopupMenu)
90 {
92 idCmdFirst = Shell_MergeMenus(lpQcmInfo->hmenu,
93 hPopupMenu,
94 lpQcmInfo->indexMenu,
95 lpQcmInfo->idCmdFirst,
96 lpQcmInfo->idCmdLast,
97 uFlags);
98 DestroyMenu(hPopupMenu);
99 }
100 }
101
102 if (uPopupMerge)
103 {
104 hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(uPopupMerge));
105 if (hPopupMenu)
106 {
107 UINT id = _SHMergePopupMenus(lpQcmInfo->hmenu, hPopupMenu,
108 lpQcmInfo->idCmdFirst, lpQcmInfo->idCmdLast);
109 idCmdFirst = max(idCmdFirst, id);
110 DestroyMenu(hPopupMenu);
111 }
112 }
113
114 lpQcmInfo->idCmdFirst = idCmdFirst;
115}
HINSTANCE hInstance
Definition: charmap.c:19
UINT uFlags
Definition: api.c:59
static INT _SHMergePopupMenus(HMENU hMenu, HMENU hPopupMenu, UINT uIDAdjust, UINT uIDAdjustMax)
Definition: utils.cpp:35
static HMENU SHLoadPopupMenu(HINSTANCE hInstance, UINT uMenuId)
Definition: utils.cpp:61
unsigned int UINT
Definition: ndis.h:50
#define MM_DONTREMOVESEPS
Definition: shlobj.h:2538
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)

◆ CopyStreamUI()

EXTERN_C HRESULT WINAPI CopyStreamUI ( _In_ IStream pSrc,
_Out_ IStream pDst,
_Inout_opt_ IProgressDialog *  pProgress,
_In_opt_ DWORDLONG  dwlSize 
)

Definition at line 1431 of file utils.cpp.

1436{
1437 HRESULT hr = E_FAIL;
1438 DWORD cbBuff, cbRead, dwSizeToWrite;
1439 DWORDLONG cbDone;
1440 LPVOID pBuff;
1441 CComHeapPtr<BYTE> pHeapPtr;
1442 STATSTG Stat;
1443 BYTE abBuff[1024];
1444
1445 TRACE("(%p, %p, %p, %I64u)\n", pSrc, pDst, pProgress, dwlSize);
1446
1447 if (dwlSize == 0) // Invalid size?
1448 {
1449 // Get the stream size
1450 ZeroMemory(&Stat, sizeof(Stat));
1451 if (FAILED(pSrc->Stat(&Stat, STATFLAG_NONAME)))
1452 pProgress = NULL; // No size info. Disable progress
1453 else
1454 dwlSize = Stat.cbSize.QuadPart;
1455 }
1456
1457 if (!pProgress) // Progress is disabled?
1458 {
1459 ULARGE_INTEGER uliSize;
1460
1461 if (dwlSize > 0)
1462 uliSize.QuadPart = dwlSize;
1463 else
1464 uliSize.HighPart = uliSize.LowPart = INVALID_FILE_SIZE;
1465
1466 return pSrc->CopyTo(pDst, uliSize, NULL, NULL); // One punch
1467 }
1468
1469 // Allocate the buffer if necessary
1470 if (dwlSize > 0 && dwlSize <= sizeof(abBuff))
1471 {
1472 cbBuff = sizeof(abBuff);
1473 pBuff = abBuff;
1474 }
1475 else
1476 {
1477#define COPY_STREAM_DEFAULT_BUFFER_SIZE 0x4000
1479 if (pHeapPtr.AllocateBytes(cbBuff))
1480 {
1481 pBuff = pHeapPtr;
1482 }
1483 else // Low memory?
1484 {
1485 cbBuff = sizeof(abBuff);
1486 pBuff = abBuff;
1487 }
1488#undef COPY_STREAM_DEFAULT_BUFFER_SIZE
1489 }
1490
1491 // Start reading
1493 zero.QuadPart = 0;
1494 pSrc->Seek(zero, 0, NULL);
1495 pDst->Seek(zero, 0, NULL);
1496 cbDone = 0;
1497 pProgress->SetProgress64(cbDone, dwlSize);
1498
1499 // Repeat reading and writing until goal
1500 for (;;)
1501 {
1502 hr = pSrc->Read(pBuff, cbBuff, &cbRead);
1503 if (FAILED(hr))
1504 break;
1505
1506 // Calculate the size to write
1507 if (dwlSize > 0)
1508 dwSizeToWrite = (DWORD)min((DWORDLONG)(dwlSize - cbDone), (DWORDLONG)cbRead);
1509 else
1510 dwSizeToWrite = cbRead;
1511
1512 if (dwSizeToWrite == 0) // No need to write?
1513 {
1514 hr = S_OK;
1515 break;
1516 }
1517
1518 hr = pDst->Write(pBuff, dwSizeToWrite, NULL);
1519 if (hr != S_OK)
1520 break;
1521
1522 cbDone += dwSizeToWrite;
1523
1524 if (pProgress->HasUserCancelled()) // Cancelled?
1525 {
1527 break;
1528 }
1529 pProgress->SetProgress64(cbDone, dwlSize);
1530
1531 if (dwlSize > 0 && cbDone >= dwlSize) // Reached the goal?
1532 {
1533 hr = S_OK;
1534 break;
1535 }
1536 }
1537
1538 return hr;
1539}
bool AllocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:127
#define E_FAIL
Definition: ddrawi.h:102
#define COPY_STREAM_DEFAULT_BUFFER_SIZE
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define Stat
Definition: syshdrs.h:78
#define ZeroMemory
Definition: minwinbase.h:31
#define min(a, b)
Definition: monoChain.cc:55
#define DWORD
Definition: nt_native.h:44
int zero
Definition: sehframes.cpp:29
$ULONG LowPart
Definition: ntbasedef.h:581
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:582
#define INVALID_FILE_SIZE
Definition: winbase.h:528
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_CANCELLED
Definition: winerror.h:1055
unsigned char BYTE
Definition: xxhash.c:193

◆ DCIA_AddEntry()

int DCIA_AddEntry ( HDCIA  hDCIA,
REFCLSID  rClsId 
)

Definition at line 1907 of file utils.cpp.

1908{
1909 for (UINT i = 0;; ++i)
1910 {
1911 const CLSID *pClsId = DCIA_GetEntry(hDCIA, i);
1912 if (!pClsId)
1913 break;
1914 if (IsEqualGUID(*pClsId, rClsId))
1915 return i; // Don't allow duplicates
1916 }
1917 return DSA_AppendItem((HDSA)hDCIA, const_cast<CLSID*>(&rClsId));
1918}
#define DCIA_GetEntry(hDCIA, iItem)
Definition: utils.h:127
#define DSA_AppendItem(hdsa, pitem)
Definition: commctrl.h:4832
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: dsa.c:45

Referenced by DCIA_AddShellExSubkey().

◆ DCIA_AddShellExSubkey()

void DCIA_AddShellExSubkey ( HDCIA  hDCIA,
HKEY  hProgId,
PCWSTR  pszSubkey 
)

Definition at line 1920 of file utils.cpp.

1921{
1922 WCHAR szKey[200];
1923 PathCombineW(szKey, L"shellex", pszSubkey);
1924 HKEY hEnum;
1925 if (RegOpenKeyExW(hProgId, szKey, 0, KEY_READ, &hEnum) != ERROR_SUCCESS)
1926 return;
1927 for (UINT i = 0; RegEnumKeyW(hEnum, i++, szKey, _countof(szKey)) == ERROR_SUCCESS;)
1928 {
1929 CLSID clsid;
1930 if (SUCCEEDED(SHELL_GetShellExtensionRegCLSID(hEnum, szKey, &clsid)))
1931 DCIA_AddEntry(hDCIA, clsid);
1932 }
1933 RegCloseKey(hEnum);
1934}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
int DCIA_AddEntry(HDCIA hDCIA, REFCLSID rClsId)
Definition: utils.cpp:1907
const CLSID * clsid
Definition: msctf.cpp:50
#define KEY_READ
Definition: nt_native.h:1026
#define PathCombineW
Definition: pathcch.h:318
short WCHAR
Definition: pedump.c:58
#define _countof(array)
Definition: sndvol32.h:70
HRESULT SHELL_GetShellExtensionRegCLSID(HKEY hKey, LPCWSTR KeyName, CLSID *pClsId)
Definition: propsheet.cpp:13

Referenced by CFSDropTarget::_GetEffectFromMenu().

◆ DisplayNameOfW()

EXTERN_C HRESULT WINAPI DisplayNameOfW ( _In_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ DWORD  dwFlags,
_Out_ LPWSTR  pszBuf,
_In_ UINT  cchBuf 
)

Definition at line 504 of file utils.cpp.

510{
511 *pszBuf = UNICODE_NULL;
512 STRRET sr;
513 HRESULT hr = psf->GetDisplayNameOf(pidl, dwFlags, &sr);
514 if (FAILED(hr))
515 return hr;
516 return StrRetToBufW(&sr, pidl, pszBuf, cchBuf);
517}
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1660
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define UNICODE_NULL
_In_ UINT cchBuf
Definition: shlwapi.h:378

Referenced by SHGetNameAndFlagsW().

◆ DynamicPathCommonPrefixW()

static INT DynamicPathCommonPrefixW ( _In_ LPCWSTR  lpszPath1,
_In_ LPCWSTR  lpszPath2,
_Out_ CStringW strPath 
)
static

Definition at line 1599 of file utils.cpp.

1603{
1604 SIZE_T cchPath1 = wcslen(lpszPath1);
1605 SIZE_T cchPath2 = wcslen(lpszPath2);
1606 LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16);
1607 INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath);
1608 strPath.ReleaseBuffer();
1609 return ret;
1610}
int WINAPI PathCommonPrefixW(const WCHAR *file1, const WCHAR *file2, WCHAR *path)
Definition: path.c:1620
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
return ret
Definition: mutex.c:146
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by PathIsEqualOrSubFolder().

◆ DynamicPathRemoveBackslashW()

static VOID DynamicPathRemoveBackslashW ( _Out_ CStringW strPath)
static

Definition at line 1671 of file utils.cpp.

1673{
1674 INT nLength = strPath.GetLength();
1675 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1676 strPath = strPath.Left(nLength - 1);
1677}
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682

Referenced by PathIsEqualOrSubFolder().

◆ DynamicSHGetPathFromIDListW()

static HRESULT DynamicSHGetPathFromIDListW ( _In_ LPCITEMIDLIST  pidl,
_Out_ CStringW strPath 
)
static

Definition at line 1616 of file utils.cpp.

1619{
1620 HRESULT hr;
1621
1622 for (UINT cchPath = MAX_PATH;; cchPath *= 2)
1623 {
1624 LPWSTR lpszPath = strPath.GetBuffer(cchPath);
1625 if (!lpszPath)
1626 return E_OUTOFMEMORY;
1627
1628 hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath);
1629 strPath.ReleaseBuffer();
1630
1632 break;
1633
1634 if (cchPath >= MAXUINT / 2)
1635 {
1636 hr = E_FAIL;
1637 break;
1638 }
1639 }
1640
1641 if (FAILED(hr))
1642 strPath.Empty();
1643
1644 return hr;
1645}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define MAX_PATH
Definition: compat.h:34
EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax)
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437

Referenced by DynamicSHGetSpecialFolderPathW().

◆ DynamicSHGetSpecialFolderPathW()

static HRESULT DynamicSHGetSpecialFolderPathW ( _In_ HWND  hwndOwner,
_Out_ CStringW strPath,
_In_ INT  nCSIDL,
_In_ BOOL  bCreate 
)
static

Definition at line 1648 of file utils.cpp.

1653{
1654 LPITEMIDLIST pidl;
1655 HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl);
1656 if (SUCCEEDED(hr))
1657 {
1658 hr = DynamicSHGetPathFromIDListW(pidl, strPath);
1659 CoTaskMemFree(pidl);
1660 }
1661
1662 if (FAILED(hr))
1663 strPath.Empty();
1664 else if (bCreate)
1665 CreateDirectoryW(strPath, NULL);
1666
1667 return hr;
1668}
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
static HRESULT DynamicSHGetPathFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
Definition: utils.cpp:1616
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3384
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1527
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by PathIsEqualOrSubFolder().

◆ ExtractIconResInfoA()

EXTERN_C WORD WINAPI ExtractIconResInfoA ( _In_ HANDLE  hHandle,
_In_ LPCSTR  lpFileName,
_In_ WORD  wIndex,
_Out_ LPWORD  lpSize,
_Out_ LPHANDLE  lpIcon 
)

Definition at line 747 of file utils.cpp.

753{
754 TRACE("(%p, %s, %u, %p, %p)\n", hHandle, debugstr_a(lpFileName), wIndex, lpSize, lpIcon);
755
756 if (!lpFileName)
757 return 0;
758
759 CStringW strFileNameW(lpFileName);
760 return ExtractIconResInfoW(hHandle, strFileNameW, wIndex, lpSize, lpIcon);
761}
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:639
#define debugstr_a
Definition: kernel32.h:31
_In_ LPCSTR lpFileName
Definition: winbase.h:2824

◆ FindVerbMapEntry()

static const CMVERBMAP * FindVerbMapEntry ( UINT_PTR  CmdId,
const CMVERBMAP pMap 
)
static

Definition at line 1863 of file utils.cpp.

1864{
1865 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1866 {
1867 if (pMap[i].CmdId == CmdId)
1868 return &pMap[i];
1869 }
1870 return NULL;
1871}
LPCSTR Verb
Definition: utils.h:88

Referenced by SHELL_GetCommandStringImpl().

◆ GetCommandStringA()

static HRESULT GetCommandStringA ( _In_ IContextMenu pCM,
_In_ UINT_PTR  Id,
_In_ UINT  GCS,
_Out_writes_(cchMax) LPSTR  Buf,
_In_ UINT  cchMax 
)
static

Definition at line 1813 of file utils.cpp.

1814{
1815 HRESULT hr = pCM->GetCommandString(Id, GCS & ~GCS_UNICODE, NULL, Buf, cchMax);
1816 if (FAILED(hr))
1817 {
1819 hr = pCM->GetCommandString(Id, GCS | GCS_UNICODE, NULL, (LPSTR)buf, _countof(buf));
1820 if (SUCCEEDED(hr))
1821 hr = SHUnicodeToAnsi(buf, Buf, cchMax) > 0 ? S_OK : E_FAIL;
1822 }
1823 return hr;
1824}
DWORD Id
UINT cchMax
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2927
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * LPSTR
Definition: typedefs.h:51

Referenced by GetDfmCmd().

◆ GetDfmCmd()

UINT GetDfmCmd ( _In_ IContextMenu pCM,
_In_ LPCSTR  verba 
)

Definition at line 1827 of file utils.cpp.

1828{
1829 CHAR buf[MAX_PATH];
1830 if (IS_INTRESOURCE(verba))
1831 {
1832 if (FAILED(GetCommandStringA(pCM, LOWORD(verba), GCS_VERB, buf, _countof(buf))))
1833 return 0;
1834 verba = buf;
1835 }
1836 return MapVerbToDfmCmd(verba); // Returns DFM_CMD_* or 0
1837}
UINT MapVerbToDfmCmd(_In_ LPCSTR verba)
#define IS_INTRESOURCE(x)
Definition: loader.c:613
static HRESULT GetCommandStringA(_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
Definition: utils.cpp:1813
#define LOWORD(l)
Definition: pedump.c:82
char CHAR
Definition: pedump.c:57

Referenced by BrFolder_OnContextMenu().

◆ Int64GetNumFormat()

static VOID Int64GetNumFormat ( _Out_ NUMBERFMTW pDest,
_In_opt_ const NUMBERFMTW pSrc,
_In_ DWORD  dwNumberFlags,
_Out_writes_(cchDecimal) LPWSTR  pszDecimal,
_In_ INT  cchDecimal,
_Out_writes_(cchThousand) LPWSTR  pszThousand,
_In_ INT  cchThousand 
)
static

Definition at line 1314 of file utils.cpp.

1322{
1323 WCHAR szBuff[20];
1324
1325 if (pSrc)
1326 *pDest = *pSrc;
1327 else
1328 dwNumberFlags = 0;
1329
1330 if (!(dwNumberFlags & FMT_USE_NUMDIGITS))
1331 {
1333 pDest->NumDigits = StrToIntW(szBuff);
1334 }
1335
1336 if (!(dwNumberFlags & FMT_USE_LEADZERO))
1337 {
1339 pDest->LeadingZero = StrToIntW(szBuff);
1340 }
1341
1342 if (!(dwNumberFlags & FMT_USE_GROUPING))
1343 {
1345 pDest->Grouping = StrToIntW(szBuff);
1346 }
1347
1348 if (!(dwNumberFlags & FMT_USE_DECIMAL))
1349 {
1350 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, pszDecimal, cchDecimal);
1351 pDest->lpDecimalSep = pszDecimal;
1352 }
1353
1354 if (!(dwNumberFlags & FMT_USE_THOUSAND))
1355 {
1356 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, pszThousand, cchThousand);
1357 pDest->lpThousandSep = pszThousand;
1358 }
1359
1360 if (!(dwNumberFlags & FMT_USE_NEGNUMBER))
1361 {
1363 pDest->NegativeOrder = StrToIntW(szBuff);
1364 }
1365}
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:407
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
#define LOCALE_USER_DEFAULT
#define FMT_USE_THOUSAND
Definition: undocshell.h:907
#define FMT_USE_GROUPING
Definition: undocshell.h:905
#define FMT_USE_NUMDIGITS
Definition: undocshell.h:903
#define FMT_USE_NEGNUMBER
Definition: undocshell.h:908
#define FMT_USE_LEADZERO
Definition: undocshell.h:904
#define FMT_USE_DECIMAL
Definition: undocshell.h:906
#define LOCALE_SGROUPING
Definition: winnls.h:51
#define LOCALE_SDECIMAL
Definition: winnls.h:49
#define LOCALE_IDIGITS
Definition: winnls.h:52
#define LOCALE_STHOUSAND
Definition: winnls.h:50
#define LOCALE_INEGNUMBER
Definition: winnls.h:54
#define LOCALE_ILZERO
Definition: winnls.h:53

Referenced by Int64ToString().

◆ Int64ToStr()

static HRESULT Int64ToStr ( _In_ LONGLONG  llValue,
_Out_writes_(cchValue) LPWSTR  pszValue,
_In_ UINT  cchValue 
)
static

Definition at line 1269 of file utils.cpp.

1273{
1274 WCHAR szBuff[40];
1275 UINT ich = 0, ichValue;
1276#if (WINVER >= _WIN32_WINNT_VISTA)
1277 BOOL bMinus = (llValue < 0);
1278
1279 if (bMinus)
1280 llValue = -llValue;
1281#endif
1282
1283 if (cchValue <= 0)
1284 return E_FAIL;
1285
1286 do
1287 {
1288 szBuff[ich++] = (WCHAR)(L'0' + (llValue % 10));
1289 llValue /= 10;
1290 } while (llValue != 0 && ich < _countof(szBuff) - 1);
1291
1292#if (WINVER >= _WIN32_WINNT_VISTA)
1293 if (bMinus && ich < _countof(szBuff))
1294 szBuff[ich++] = '-';
1295#endif
1296
1297 for (ichValue = 0; ich > 0 && ichValue < cchValue; ++ichValue)
1298 {
1299 --ich;
1300 pszValue[ichValue] = szBuff[ich];
1301 }
1302
1303 if (ichValue >= cchValue)
1304 {
1305 pszValue[cchValue - 1] = UNICODE_NULL;
1306 return E_FAIL;
1307 }
1308
1309 pszValue[ichValue] = UNICODE_NULL;
1310 return S_OK;
1311}
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783

Referenced by Int64ToString().

◆ Int64ToString()

EXTERN_C INT WINAPI Int64ToString ( _In_ LONGLONG  llValue,
_Out_writes_(cchOut) LPWSTR  pszOut,
_In_ UINT  cchOut,
_In_ BOOL  bUseFormat,
_In_opt_ const NUMBERFMTW pNumberFormat,
_In_ DWORD  dwNumberFlags 
)

Definition at line 1374 of file utils.cpp.

1381{
1382 INT ret;
1383 NUMBERFMTW NumFormat;
1384 WCHAR szValue[80], szDecimalSep[6], szThousandSep[6];
1385
1386 Int64ToStr(llValue, szValue, _countof(szValue));
1387
1388 if (bUseFormat)
1389 {
1390 Int64GetNumFormat(&NumFormat, pNumberFormat, dwNumberFlags,
1391 szDecimalSep, _countof(szDecimalSep),
1392 szThousandSep, _countof(szThousandSep));
1393 ret = GetNumberFormatW(LOCALE_USER_DEFAULT, 0, szValue, &NumFormat, pszOut, cchOut);
1394 if (ret)
1395 --ret;
1396 return ret;
1397 }
1398
1399 if (FAILED(StringCchCopyW(pszOut, cchOut, szValue)))
1400 return 0;
1401
1402 return lstrlenW(pszOut);
1403}
#define lstrlenW
Definition: compat.h:750
static VOID Int64GetNumFormat(_Out_ NUMBERFMTW *pDest, _In_opt_ const NUMBERFMTW *pSrc, _In_ DWORD dwNumberFlags, _Out_writes_(cchDecimal) LPWSTR pszDecimal, _In_ INT cchDecimal, _Out_writes_(cchThousand) LPWSTR pszThousand, _In_ INT cchThousand)
Definition: utils.cpp:1314
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:1269
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1130
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by DoTestEntry(), LargeIntegerToString(), and Test_Int64ToString().

◆ InvokeIExecuteCommand()

EXTERN_C HRESULT InvokeIExecuteCommand ( _In_ IExecuteCommand *  pEC,
_In_ PCWSTR  pszCommandName,
_In_opt_ IPropertyBag pPB,
_In_opt_ IShellItemArray *  pSIA,
_In_opt_ LPCMINVOKECOMMANDINFOEX  pICI,
_In_opt_ IUnknown pSite 
)

Definition at line 1762 of file utils.cpp.

1769{
1770 if (!pEC)
1771 return E_INVALIDARG;
1772
1773 CScopedSetObjectWithSite site(pEC, pSite);
1774 IUnknown_InitializeCommand(pEC, pszCommandName, pPB);
1775
1777 if (pSIA && SUCCEEDED(pEC->QueryInterface(IID_PPV_ARG(IObjectWithSelection, &pOWS))))
1778 pOWS->SetSelection(pSIA);
1779
1780 DWORD dwKeyState = 0, fMask = pICI ? pICI->fMask : 0;
1781 pEC->SetNoShowUI((fMask & CMIC_MASK_FLAG_NO_UI) != 0);
1782 pEC->SetShowWindow(pICI ? pICI->nShow : SW_SHOW);
1783 if (fMask & CMIC_MASK_SHIFT_DOWN)
1784 dwKeyState |= MK_SHIFT;
1785 if (fMask & CMIC_MASK_CONTROL_DOWN)
1786 dwKeyState |= MK_CONTROL;
1787 pEC->SetKeyState(dwKeyState);
1788 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpDirectoryW)
1789 pEC->SetDirectory(pICI->lpDirectoryW);
1790 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpParametersW)
1791 pEC->SetParameters(pICI->lpParametersW);
1792 if (fMask & CMIC_MASK_PTINVOKE)
1793 pEC->SetPosition(pICI->ptInvoke);
1794
1795 return pEC->Execute();
1796}
#define E_INVALIDARG
Definition: ddrawi.h:101
EXTERN_C HRESULT IUnknown_InitializeCommand(_In_ IUnknown *pUnk, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB)
Definition: utils.cpp:1749
static IActiveScriptSite * site
Definition: script.c:149
#define MK_SHIFT
Definition: winuser.h:2405
#define MK_CONTROL
Definition: winuser.h:2406
#define SW_SHOW
Definition: winuser.h:786
#define IID_PPV_ARG(Itype, ppType)

Referenced by InvokeIExecuteCommandWithDataObject().

◆ InvokeIExecuteCommandWithDataObject()

EXTERN_C HRESULT InvokeIExecuteCommandWithDataObject ( _In_ IExecuteCommand *  pEC,
_In_ PCWSTR  pszCommandName,
_In_opt_ IPropertyBag pPB,
_In_ IDataObject pDO,
_In_opt_ LPCMINVOKECOMMANDINFOEX  pICI,
_In_opt_ IUnknown pSite 
)

Definition at line 1799 of file utils.cpp.

1806{
1808 HRESULT hr = SHCreateShellItemArrayFromDataObject(pDO, IID_PPV_ARG(IShellItemArray, &pSIA));
1809 return SUCCEEDED(hr) ? InvokeIExecuteCommand(pEC, pszCommandName, pPB, pSIA, pICI, pSite) : hr;
1810}
EXTERN_C HRESULT WINAPI SHCreateShellItemArrayFromDataObject(_In_ IDataObject *pdo, _In_ REFIID riid, _Out_ void **ppv)
Definition: CShellItem.cpp:429
EXTERN_C HRESULT InvokeIExecuteCommand(_In_ IExecuteCommand *pEC, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB, _In_opt_ IShellItemArray *pSIA, _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, _In_opt_ IUnknown *pSite)
Definition: utils.cpp:1762

Referenced by CDefaultContextMenu::InvokeRegVerb().

◆ IsShutdownAllowed()

BOOL IsShutdownAllowed ( VOID  )

Definition at line 914 of file utils.cpp.

915{
917}
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
Definition: utils.cpp:858
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:427

Referenced by IsSuspendAllowed().

◆ IsSuspendAllowed()

BOOL WINAPI IsSuspendAllowed ( VOID  )

Definition at line 922 of file utils.cpp.

923{
924 TRACE("()\n");
926}
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:914
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:713

◆ IUnknown_InitializeCommand()

EXTERN_C HRESULT IUnknown_InitializeCommand ( _In_ IUnknown pUnk,
_In_ PCWSTR  pszCommandName,
_In_opt_ IPropertyBag pPB 
)

Definition at line 1749 of file utils.cpp.

1753{
1754 HRESULT hr;
1756 if (SUCCEEDED(hr = pUnk->QueryInterface(IID_PPV_ARG(IInitializeCommand, &pIC))))
1757 hr = pIC->Initialize(pszCommandName, pPB);
1758 return hr;
1759}
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
nsresult QueryInterface(nsIIDRef riid, void **result)

Referenced by InvokeIExecuteCommand(), and CDefaultContextMenu::InvokeRegVerb().

◆ LargeIntegerToString()

EXTERN_C INT WINAPI LargeIntegerToString ( _In_ const LARGE_INTEGER pLargeInt,
_Out_writes_(cchOut) LPWSTR  pszOut,
_In_ UINT  cchOut,
_In_ BOOL  bUseFormat,
_In_opt_ const NUMBERFMTW pNumberFormat,
_In_ DWORD  dwNumberFlags 
)

Definition at line 1412 of file utils.cpp.

1419{
1420 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
1421 pNumberFormat, dwNumberFlags);
1422}
EXTERN_C INT WINAPI Int64ToString(_In_ LONGLONG llValue, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
Definition: utils.cpp:1374

Referenced by DoTestEntry(), and Test_LargeIntegerToString().

◆ LinkWindow_RegisterClass()

EXTERN_C BOOL WINAPI LinkWindow_RegisterClass ( VOID  )

Definition at line 2358 of file utils.cpp.

2359{
2360 INITCOMMONCONTROLSEX iccx = { sizeof(iccx), ICC_LINK_CLASS };
2361 InitCommonControlsEx(&iccx);
2362
2363 WNDCLASSEXW wcx = { sizeof(wcx) };
2364 if (!GetClassInfoExW(NULL, L"SysLink", &wcx))
2365 return FALSE;
2366
2367 /* Superclassing! */
2368 wcx.lpszClassName = L"Link Window";
2370}
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:904
#define ICC_LINK_CLASS
Definition: commctrl.h:74
LPCWSTR lpszClassName
Definition: winuser.h:3334
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_CLASS_ALREADY_EXISTS
Definition: winerror.h:1236
BOOL WINAPI GetClassInfoExW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSEXW)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)

◆ LinkWindow_UnregisterClass()

EXTERN_C BOOL WINAPI LinkWindow_UnregisterClass ( _In_ DWORD  dwUnused)

Definition at line 2375 of file utils.cpp.

2376{
2377 /* Do nothing. This is correct. */
2378 return TRUE;
2379}

◆ OpenEffectiveToken()

static BOOL OpenEffectiveToken ( _In_ DWORD  DesiredAccess,
_Out_ HANDLE phToken 
)
static

Definition at line 321 of file utils.cpp.

324{
325 BOOL ret;
326
327 if (phToken == NULL)
328 {
330 return FALSE;
331 }
332
333 *phToken = NULL;
334
336 if (!ret && GetLastError() == ERROR_NO_TOKEN)
338
339 return ret;
340}
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define GetCurrentProcess()
Definition: compat.h:759
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2469
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1146
#define ERROR_NO_TOKEN
Definition: winerror.h:911

Referenced by SHOpenEffectiveToken().

◆ PathIsDosDevice()

BOOL PathIsDosDevice ( _In_ LPCWSTR  pszName)

Definition at line 254 of file utils.cpp.

255{
259
260 if (lstrcmpiW(szPath, L"NUL") == 0 || lstrcmpiW(szPath, L"PRN") == 0 ||
261 lstrcmpiW(szPath, L"CON") == 0 || lstrcmpiW(szPath, L"AUX") == 0)
262 {
263 return TRUE;
264 }
265
266 if (_wcsnicmp(szPath, L"LPT", 3) == 0 || _wcsnicmp(szPath, L"COM", 3) == 0)
267 {
268 if ((L'0' <= szPath[3] && szPath[3] <= L'9') && szPath[4] == UNICODE_NULL)
269 return TRUE;
270 }
271
272 return FALSE;
273}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1946
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:195
LPCWSTR szPath
Definition: env.c:37

Referenced by CFSFolder::_CreateIDListFromName().

◆ PathIsDotOrDotDotW()

BOOL PathIsDotOrDotDotW ( _In_ LPCWSTR  pszPath)

Definition at line 228 of file utils.cpp.

229{
230 if (pszPath[0] != L'.')
231 return FALSE;
232 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
233}

Referenced by PathIsValidElement(), and CFileDefExt::WalkDirTree().

◆ PathIsEqualOrSubFolder()

EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder ( _In_ LPCWSTR  pszPath1OrCSIDL,
_In_ LPCWSTR  pszPath2 
)

Definition at line 1684 of file utils.cpp.

1687{
1688 CStringW strCommon, strPath1;
1689
1690 TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2));
1691
1692 if (IS_INTRESOURCE(pszPath1OrCSIDL))
1693 {
1695 NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE);
1696 }
1697 else
1698 {
1699 strPath1 = pszPath1OrCSIDL;
1700 }
1701
1703
1704 if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon))
1705 return FALSE;
1706
1707 return strPath1.CompareNoCase(strCommon) == 0;
1708}
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1671
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1599
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1648
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2242

Referenced by PathIsTemporaryW(), and START_TEST().

◆ PathIsSlowA()

EXTERN_C BOOL WINAPI PathIsSlowA ( _In_ LPCSTR  pszFile,
_In_ DWORD  dwAttr 
)

Definition at line 733 of file utils.cpp.

736{
737 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
738 CStringW strFileW(pszFile);
739 return PathIsSlowW(strFileW, dwAttr);
740}
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: stubs.cpp:751

◆ PathIsValidElement()

BOOL PathIsValidElement ( _In_ LPCWSTR  pszPath)

Definition at line 240 of file utils.cpp.

241{
242 if (!*pszPath || PathIsDotOrDotDotW(pszPath))
243 return FALSE;
244
245 for (LPCWSTR pch = pszPath; *pch; ++pch)
246 {
248 return FALSE;
249 }
250
251 return TRUE;
252}
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:2221
#define PATH_VALID_ELEMENT
Definition: utils.cpp:235
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:228
#define pch(ap)
Definition: match.c:418
const uint16_t * LPCWSTR
Definition: typedefs.h:57

Referenced by Shell_NextElement().

◆ SHBindToObject()

EXTERN_C HRESULT SHBindToObject ( _In_opt_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 442 of file utils.cpp.

447{
448 return SHBindToObjectEx(psf, pidl, NULL, riid, ppvObj);
449}
HRESULT SHBindToObjectEx(_In_opt_ IShellFolder *pShellFolder, _In_ LPCITEMIDLIST pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:409
REFIID riid
Definition: atlbase.h:39

Referenced by _BindToObject(), CDesktopFolder::_ParseDisplayNameByParent(), BrFolder_InitTreeView(), CRegItemContextMenu_CreateInstance(), FileOpCallback(), SHELL_GetIDListTarget(), Shell_ParsePrinterName(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ SHBindToObjectEx()

HRESULT SHBindToObjectEx ( _In_opt_ IShellFolder pShellFolder,
_In_ LPCITEMIDLIST  pidl,
_In_opt_ IBindCtx pBindCtx,
_In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 409 of file utils.cpp.

415{
416 CComPtr<IShellFolder> psfDesktop;
417
418 *ppvObj = NULL;
419
420 if (!pShellFolder)
421 {
422 SHGetDesktopFolder(&psfDesktop);
423 if (!psfDesktop)
424 return E_FAIL;
425
426 pShellFolder = psfDesktop;
427 }
428
429 HRESULT hr;
430 if (_ILIsDesktop(pidl))
431 hr = pShellFolder->QueryInterface(riid, ppvObj);
432 else
433 hr = pShellFolder->BindToObject(pidl, pBindCtx, riid, ppvObj);
434
435 if (SUCCEEDED(hr) && !*ppvObj)
436 hr = E_FAIL;
437
438 return hr;
439}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)

Referenced by SHBindToObject().

◆ SHCoInitializeAnyApartment()

HRESULT SHCoInitializeAnyApartment ( VOID  )

Definition at line 566 of file utils.cpp.

567{
569 if (FAILED(hr))
571 return hr;
572}
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:281

Referenced by ShellExecuteExW(), SHGetNameAndFlagsW(), and SHSetLocalizedName().

◆ SHCreatePropertyBag()

EXTERN_C HRESULT WINAPI SHCreatePropertyBag ( _In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 975 of file utils.cpp.

976{
978}
#define STGM_READWRITE
Definition: objbase.h:938
EXTERN_C HRESULT WINAPI SHCreatePropertyBagOnMemory(_In_ DWORD dwMode, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: propbag.cpp:254

◆ SHELL32_AliasTranslatePidl()

EXTERN_C HRESULT SHELL32_AliasTranslatePidl ( _In_ LPCITEMIDLIST  pidl,
_Out_ LPITEMIDLIST ppidlNew,
_In_ DWORD  dwFlags 
)

Translate a PIDL to an "alias" PIDL.

Definition at line 2345 of file utils.cpp.

2349{
2350 return SHELL32_ReparentAsAliasPidl(NULL, NULL, pidl, ppidlNew, dwFlags) ? S_OK : E_FAIL;
2351}
EXTERN_C BOOL SHELL32_ReparentAsAliasPidl(_In_opt_ HWND hwnd, _In_opt_ HANDLE hToken, _In_ LPCITEMIDLIST pidlTarget, _Out_ LPITEMIDLIST *ppidlNew, _In_ DWORD dwFlags)
Translate a PIDL to an "alias" PIDL.
Definition: utils.cpp:2206

Referenced by CreateNotificationParamAndSend(), CDesktopFolder::ParseDisplayName(), and SHLogILFromFSIL().

◆ SHELL32_ReparentAsAliasPidl()

EXTERN_C BOOL SHELL32_ReparentAsAliasPidl ( _In_opt_ HWND  hwnd,
_In_opt_ HANDLE  hToken,
_In_ LPCITEMIDLIST  pidlTarget,
_Out_ LPITEMIDLIST ppidlNew,
_In_ DWORD  dwFlags 
)

Translate a PIDL to an "alias" PIDL.

Definition at line 2206 of file utils.cpp.

2212{
2213 if (!pidlTarget || !ppidlNew)
2214 return FALSE;
2215
2216 *ppidlNew = NULL;
2217
2218 for (SIZE_T iEntry = 0; iEntry < _countof(g_AliasTable); ++iEntry)
2219 {
2220 const ALIAS_MAPPING *pEntry = &g_AliasTable[iEntry];
2221
2222 if (!(dwFlags & pEntry->bFlagMask))
2223 continue;
2224
2225 // Get the source root PIDL
2226 LPITEMIDLIST pidlSrcRoot = NULL;
2227 HRESULT hr = SHGetFolderLocation(hwnd, pEntry->nCsidlSrc, hToken, 0, &pidlSrcRoot);
2228 if (FAILED(hr))
2229 continue;
2230
2231 // Check whether the input pidlTarget is under the source folder.
2232 // If it matches, ILFindChild returns the relative PIDL in the pidlTarget.
2233 LPCITEMIDLIST pidlRelative = ILFindChild(pidlSrcRoot, pidlTarget);
2234 if (!pidlRelative) // Not found?
2235 {
2236 ILFree(pidlSrcRoot);
2237 continue;
2238 }
2239
2240 // Found. Get the destination root PIDL
2241 LPITEMIDLIST pidlDestRoot = NULL;
2242 hr = SHGetFolderLocation(hwnd, pEntry->nCsidlDest, hToken, 0, &pidlDestRoot);
2243 if (SUCCEEDED(hr))
2244 {
2245 // Create a new PIDL by combining the destination root PIDL and the relative PIDL
2246 *ppidlNew = ILCombine(pidlDestRoot, pidlRelative);
2247 if (*ppidlNew)
2248 {
2249 // Manipulate specific flags in the PIDL if necessary
2250 if (pEntry->bCommonDesktop && (*ppidlNew)->mkid.cb >= 3)
2251 {
2252 (*ppidlNew)->mkid.abID[0] |= (PT_FS | PT_FS_COMMON_FLAG);
2253 }
2254 }
2255 ILFree(pidlDestRoot);
2256 }
2257
2258 ILFree(pidlSrcRoot);
2259 break; // A match was found, so exit the loop
2260 }
2261
2262 return (*ppidlNew != NULL);
2263}
static const ALIAS_MAPPING g_AliasTable[]
PIDL alias table.
Definition: utils.cpp:2176
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3277
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define PT_FS
Definition: lnktool.cpp:40
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
PUIDLIST_RELATIVE WINAPI ILFindChild(PIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2)
Definition: pidl.c:751
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42

Referenced by SHELL32_AliasTranslatePidl().

◆ SHELL_BuildDisplayMachineName()

static HRESULT SHELL_BuildDisplayMachineName ( _Out_writes_z_(cchNameMax) PWSTR  pszName,
_In_ DWORD  cchNameMax,
_In_ PCWSTR  pszServerName,
_In_ PCWSTR  pszDescription 
)
static

Definition at line 2088 of file utils.cpp.

2093{
2094 if (!pszDescription || !*pszDescription)
2095 return E_FAIL;
2096
2097 PCWSTR pszFormat = (SHRestricted(REST_ALLOWCOMMENTTOGGLE) ? L"%2 (%1)" : L"%1 (%2)");
2098 PCWSTR args[] = { pszDescription , SHELL_SkipServerSlashes(pszServerName) };
2100 pszFormat, 0, 0, pszName, cchNameMax, (va_list *)args) ? S_OK : E_FAIL);
2101}
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
char * va_list
Definition: vadefs.h:50
static PCWSTR SHELL_SkipServerSlashes(_In_ PCWSTR pszPath)
Definition: utils.cpp:2023
@ REST_ALLOWCOMMENTTOGGLE
Definition: shlobj.h:1878
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:166
Definition: match.c:390
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:398
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:401

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_CacheComputerDescription()

static VOID SHELL_CacheComputerDescription ( _In_ PCWSTR  pszServerName,
_In_ PCWSTR  pszDesc 
)
static

Definition at line 2051 of file utils.cpp.

2054{
2055 if (!pszDesc)
2056 return;
2057
2058 SIZE_T cbDesc = (wcslen(pszDesc) + 1) * sizeof(WCHAR);
2060 SHELL_SkipServerSlashes(pszServerName), REG_SZ, pszDesc, (DWORD)cbDesc);
2061}
#define COMPUTER_DESCRIPTIONS_KEY
Definition: utils.cpp:2033
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1348
#define REG_SZ
Definition: layer.c:22
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_CreateShell32DefaultExtractIcon()

HRESULT SHELL_CreateShell32DefaultExtractIcon ( int  IconIndex,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 1897 of file utils.cpp.

1898{
1902 return hr;
1903 initIcon->SetNormalIcon(swShell32Name, IconIndex);
1904 return initIcon->QueryInterface(riid, ppvOut);
1905}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
static const WCHAR IconIndex[]
Definition: install.c:52
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22

Referenced by SHELL_CreateFallbackExtractIconForFolder(), and SHELL_CreateFallbackExtractIconForNoAssocFile().

◆ SHELL_DisplayNameOf()

HRESULT SHELL_DisplayNameOf ( _In_opt_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_opt_ UINT  Flags,
_Out_ PWSTR ppStr 
)

Definition at line 478 of file utils.cpp.

483{
484 HRESULT hr;
485 CComPtr<IShellFolder> psfRoot;
486 if (!psf)
487 {
488 PCUITEMID_CHILD pidlChild;
489 hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfRoot), &pidlChild);
490 if (FAILED(hr))
491 return hr;
492 psf = psfRoot;
493 pidl = pidlChild;
494 }
495 STRRET sr;
496 hr = psf->GetDisplayNameOf((PCUITEMID_CHILD)pidl, Flags, &sr);
497 return SUCCEEDED(hr) ? StrRetToStrW(&sr, pidl, ppStr) : hr;
498}
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1761
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1504
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by CFileDefExt::InitMultifilePageThread().

◆ Shell_FailForceReturn()

BOOL Shell_FailForceReturn ( _In_ HRESULT  hr)

Definition at line 392 of file utils.cpp.

393{
395
396 switch (code)
397 {
400 case ERROR_CANCELLED:
401 return TRUE;
402
403 default:
405 }
406}
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
Definition: inflate.c:139
#define ERROR_BAD_NETPATH
Definition: winerror.h:267
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define HRESULT_CODE(hr)
Definition: winerror.h:188
#define ERROR_BAD_NET_NAME
Definition: winerror.h:281

Referenced by CDesktopFolder::ParseDisplayName(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ SHELL_GetCachedComputerDescription()

static HRESULT SHELL_GetCachedComputerDescription ( _Out_writes_z_(cchDescMax) PWSTR  pszDesc,
_In_ DWORD  cchDescMax,
_In_ PCWSTR  pszServerName 
)
static

Definition at line 2038 of file utils.cpp.

2042{
2043 cchDescMax *= sizeof(WCHAR);
2045 SHELL_SkipServerSlashes(pszServerName), NULL, pszDesc, &cchDescMax);
2046 return HRESULT_FROM_WIN32(error);
2047}
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1278
#define error(str)
Definition: mkdosfs.c:1605

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_GetCommandStringImpl()

HRESULT SHELL_GetCommandStringImpl ( SIZE_T  CmdId,
UINT  uFlags,
LPSTR  Buf,
UINT  cchBuf,
const CMVERBMAP pMap 
)

Definition at line 1874 of file utils.cpp.

1875{
1876 const CMVERBMAP* pEntry;
1877 switch (uFlags | GCS_UNICODE)
1878 {
1879 case GCS_VALIDATEW:
1880 case GCS_VERBW:
1881 pEntry = FindVerbMapEntry(CmdId, pMap);
1882 if ((uFlags | GCS_UNICODE) == GCS_VERBW)
1883 {
1884 if (!pEntry)
1885 return E_INVALIDARG;
1886 else if (uFlags & GCS_UNICODE)
1887 return SHAnsiToUnicode(pEntry->Verb, (LPWSTR)Buf, cchBuf) ? S_OK : E_FAIL;
1888 else
1889 return StringCchCopyA(Buf, cchBuf, pEntry->Verb);
1890 }
1891 return pEntry ? S_OK : S_FALSE; // GCS_VALIDATE
1892 }
1893 return E_NOTIMPL;
1894}
#define E_NOTIMPL
Definition: ddrawi.h:99
static const CMVERBMAP * FindVerbMapEntry(UINT_PTR CmdId, const CMVERBMAP *pMap)
Definition: utils.cpp:1863
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2803
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
#define S_FALSE
Definition: winerror.h:3451

Referenced by CCopyAsPathMenu::GetCommandString(), COpenWithMenu::GetCommandString(), CRecycleBinItemContextMenu::GetCommandString(), and CRecycleBin::GetCommandString().

◆ SHELL_GetComputerDescription()

static HRESULT SHELL_GetComputerDescription ( _Out_writes_z_(cchDescMax) PWSTR  pszDesc,
_In_ SIZE_T  cchDescMax,
_In_ PWSTR  pszServerName 
)
static

Definition at line 2065 of file utils.cpp.

2069{
2071 NET_API_STATUS error = NetServerGetInfo(pszServerName, 101, (PBYTE*)&bufptr);
2074 return hr;
2075
2076 PCWSTR comment = bufptr->sv101_comment;
2077 if (comment && comment[0])
2078 StringCchCopyW(pszDesc, cchDescMax, comment);
2079 else
2080 hr = E_FAIL;
2081
2083 return hr;
2084}
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
#define comment(fmt, arg1)
Definition: rebar.c:847
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
BYTE * PBYTE
Definition: pedump.c:66
static unsigned int bufptr
Definition: tncon.cpp:77

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_GetIDListTarget()

HRESULT SHELL_GetIDListTarget ( _In_ LPCITEMIDLIST  pidl,
_Out_ PIDLIST_ABSOLUTE ppidl 
)

Definition at line 554 of file utils.cpp.

555{
556 IShellLink *pSL;
557 HRESULT hr = SHBindToObject(NULL, pidl, IID_PPV_ARG(IShellLink, &pSL));
558 if (SUCCEEDED(hr))
559 {
560 hr = pSL->GetIDList(ppidl); // Note: Returns S_FALSE if no target pidl
561 pSL->Release();
562 }
563 return hr;
564}
EXTERN_C HRESULT SHBindToObject(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:442

Referenced by SHBrowseForFolderW().

◆ SHELL_GetUIObjectOfAbsoluteItem()

EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem ( _In_opt_ HWND  hWnd,
_In_ PCIDLIST_ABSOLUTE  pidl,
_In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 452 of file utils.cpp.

456{
457 if (!ppvObj)
458 return E_INVALIDARG;
459 *ppvObj = NULL;
460 IShellFolder *psf;
461 PCUITEMID_CHILD pidlChild;
462 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlChild);
463 if (SUCCEEDED(hr))
464 {
465 hr = psf->GetUIObjectOf(hWnd, 1, &pidlChild, riid, NULL, ppvObj);
466 psf->Release();
467 if (SUCCEEDED(hr))
468 {
469 if (*ppvObj)
470 return hr;
471 hr = E_FAIL;
472 }
473 }
474 return hr;
475}
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)

Referenced by CShellLink::DragEnter(), CSendToMenu::GetUIObjectFromPidl(), CFolderItemVerbs::Init(), SHELL_PidlGetIconLocationW(), and shellex_get_dataobj().

◆ SHELL_MapContextMenuVerbToCmdId()

HRESULT SHELL_MapContextMenuVerbToCmdId ( LPCMINVOKECOMMANDINFO  pICI,
const CMVERBMAP pMap 
)

Definition at line 1840 of file utils.cpp.

1841{
1842 LPCSTR pVerbA = pICI->lpVerb;
1843 CHAR buf[MAX_PATH];
1844 LPCMINVOKECOMMANDINFOEX pICIX = (LPCMINVOKECOMMANDINFOEX)pICI;
1845 if (IsUnicode(*pICIX) && !IS_INTRESOURCE(pICIX->lpVerbW))
1846 {
1847 if (SHUnicodeToAnsi(pICIX->lpVerbW, buf, _countof(buf)))
1848 pVerbA = buf;
1849 }
1850
1851 if (IS_INTRESOURCE(pVerbA))
1852 return LOWORD(pVerbA);
1853 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1854 {
1855 assert(SUCCEEDED((int)(pMap[i].CmdId))); // The id must be >= 0 and ideally in the 0..0x7fff range
1856 if (!lstrcmpiA(pMap[i].Verb, pVerbA) && pVerbA[0])
1857 return pMap[i].CmdId;
1858 }
1859 return E_FAIL;
1860}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
#define assert(_expr)
Definition: assert.h:32
WORD CmdId
Definition: utils.h:89
const char * LPCSTR
Definition: typedefs.h:52

Referenced by CCopyAsPathMenu::InvokeCommand(), COpenWithMenu::InvokeCommand(), CRecycleBinItemContextMenu::InvokeCommand(), and CRecycleBin::InvokeCommand().

◆ SHELL_ReadSingleUnreadMailCount()

static DWORD SHELL_ReadSingleUnreadMailCount ( _In_ HKEY  hKey,
_Out_opt_ PDWORD  pdwCount,
_Out_opt_ PFILETIME  pFileTime,
_Out_writes_opt_(cchShellExecuteCommand) LPWSTR  pszShellExecuteCommand,
_In_ INT  cchShellExecuteCommand 
)
static

Definition at line 982 of file utils.cpp.

988{
989 DWORD dwType, dwCount, cbSize = sizeof(dwCount);
990 DWORD error = SHQueryValueExW(hKey, L"MessageCount", 0, &dwType, &dwCount, &cbSize);
991 if (error)
992 return error;
993 if (pdwCount && dwType == REG_DWORD)
994 *pdwCount = dwCount;
995
996 FILETIME FileTime;
997 cbSize = sizeof(FileTime);
998 error = SHQueryValueExW(hKey, L"TimeStamp", 0, &dwType, &FileTime, &cbSize);
999 if (error)
1000 return error;
1001 if (pFileTime && dwType == REG_BINARY)
1002 *pFileTime = FileTime;
1003
1004 WCHAR szName[2 * MAX_PATH];
1005 cbSize = sizeof(szName);
1006 error = SHQueryValueExW(hKey, L"Application", 0, &dwType, szName, &cbSize);
1007 if (error)
1008 return error;
1009
1010 if (pszShellExecuteCommand && dwType == REG_SZ &&
1011 FAILED(StringCchCopyW(pszShellExecuteCommand, cchShellExecuteCommand, szName)))
1012 {
1014 }
1015
1016 return ERROR_SUCCESS;
1017}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1503
FxAutoRegKey hKey
#define REG_BINARY
Definition: nt_native.h:1499
static const WCHAR szName[]
Definition: powrprof.c:45
#define REG_DWORD
Definition: sdbapi.c:615

Referenced by SHGetUnreadMailCountW().

◆ SHELL_SkipServerSlashes()

static PCWSTR SHELL_SkipServerSlashes ( _In_ PCWSTR  pszPath)
static

Definition at line 2023 of file utils.cpp.

2025{
2026 PCWSTR pch;
2027 for (pch = pszPath; *pch == L'\\'; ++pch)
2028 ;
2029 return pch;
2030}

Referenced by SHELL_BuildDisplayMachineName(), SHELL_CacheComputerDescription(), SHELL_GetCachedComputerDescription(), and SHGetComputerDisplayNameW().

◆ SHEnumerateUnreadMailAccountsW()

EXTERN_C HRESULT WINAPI SHEnumerateUnreadMailAccountsW ( _In_opt_ HKEY  hKeyUser,
_In_ DWORD  dwIndex,
_Out_writes_(cchMailAddress) PWSTR  pszMailAddress,
_In_ INT  cchMailAddress 
)

Definition at line 1209 of file utils.cpp.

1214{
1215 if (!hKeyUser)
1216 hKeyUser = HKEY_CURRENT_USER;
1217
1218 HKEY hKey;
1219 LSTATUS error = RegOpenKeyExW(hKeyUser,
1220 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail",
1222 if (error)
1223 return HRESULT_FROM_WIN32(error);
1224
1225 FILETIME FileTime;
1226 error = RegEnumKeyExW(hKey, dwIndex, pszMailAddress, (PDWORD)&cchMailAddress, NULL, NULL,
1227 NULL, &FileTime);
1228 if (error)
1229 *pszMailAddress = UNICODE_NULL;
1230
1232 return error ? HRESULT_FROM_WIN32(error) : S_OK;
1233}
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
DWORD * PDWORD
Definition: pedump.c:68

Referenced by START_TEST().

◆ SheRemoveQuotesA()

EXTERN_C LPSTR WINAPI SheRemoveQuotesA ( LPSTR  psz)

Definition at line 1159 of file utils.cpp.

1160{
1161 PCHAR pch;
1162
1163 if (*psz == '"')
1164 {
1165 for (pch = psz + 1; *pch && *pch != '"'; ++pch)
1166 {
1167 *(pch - 1) = *pch;
1168 }
1169
1170 if (*pch == '"')
1171 *(pch - 1) = ANSI_NULL;
1172 }
1173
1174 return psz;
1175}
#define ANSI_NULL
char * PCHAR
Definition: typedefs.h:51

◆ SheRemoveQuotesW()

EXTERN_C LPWSTR WINAPI SheRemoveQuotesW ( LPWSTR  psz)

Definition at line 1184 of file utils.cpp.

1185{
1186 PWCHAR pch;
1187
1188 if (*psz == L'"')
1189 {
1190 for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
1191 {
1192 *(pch - 1) = *pch;
1193 }
1194
1195 if (*pch == L'"')
1196 *(pch - 1) = UNICODE_NULL;
1197 }
1198
1199 return psz;
1200}
uint16_t * PWCHAR
Definition: typedefs.h:56

◆ SHFindComputer()

EXTERN_C BOOL WINAPI SHFindComputer ( LPCITEMIDLIST  pidlRoot,
LPCITEMIDLIST  pidlSavedSearch 
)

Definition at line 1243 of file utils.cpp.

1244{
1245 UNREFERENCED_PARAMETER(pidlRoot);
1246 UNREFERENCED_PARAMETER(pidlSavedSearch);
1247
1248 TRACE("%p %p\n", pidlRoot, pidlSavedSearch);
1249
1250 IContextMenu *pCM;
1251 HRESULT hr = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
1252 IID_IContextMenu, (void **)&pCM);
1253 if (FAILED(hr))
1254 {
1255 ERR("0x%08X\n", hr);
1256 return hr;
1257 }
1258
1259 CMINVOKECOMMANDINFO InvokeInfo = { sizeof(InvokeInfo) };
1260 InvokeInfo.lpParameters = "{996E1EB1-B524-11D1-9120-00A0C98BA67D}";
1261 InvokeInfo.nShow = SW_SHOWNORMAL;
1262 hr = pCM->InvokeCommand(&InvokeInfo);
1263 pCM->Release();
1264
1265 return SUCCEEDED(hr);
1266}
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
HRESULT InvokeCommand([in] LPCMINVOKECOMMANDINFO lpici)
#define SW_SHOWNORMAL
Definition: winuser.h:781

Referenced by CTrayWindow::HandleCommand(), and CTrayWindow::HandleHotKey().

◆ SHGetAttributes()

DWORD SHGetAttributes ( _In_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ DWORD  dwAttributes 
)

Definition at line 520 of file utils.cpp.

521{
522 LPCITEMIDLIST pidlLast = pidl;
523 IShellFolder *release = NULL;
524
525 if (!psf)
526 {
527 SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
528 if (!psf)
529 return 0;
530 release = psf;
531 }
532
533 DWORD oldAttrs = dwAttributes;
534 if (FAILED(psf->GetAttributesOf(1, &pidlLast, &dwAttributes)))
535 dwAttributes = 0;
536 else
537 dwAttributes &= oldAttrs;
538
539 if ((dwAttributes & SFGAO_FOLDER) &&
540 (dwAttributes & SFGAO_STREAM) &&
541 !(dwAttributes & SFGAO_STORAGEANCESTOR) &&
542 (oldAttrs & SFGAO_STORAGEANCESTOR) &&
543 (SHGetObjectCompatFlags(psf, NULL) & 0x200))
544 {
545 dwAttributes &= ~(SFGAO_STREAM | SFGAO_STORAGEANCESTOR);
546 dwAttributes |= SFGAO_STORAGEANCESTOR;
547 }
548
549 if (release)
550 release->Release();
551 return dwAttributes;
552}
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:6515
DWORD dwAttributes
Definition: vdmdbg.h:34

Referenced by CFSDropTarget::_DoDrop(), BrFolder_InsertItem(), CRegItemContextMenu_CreateInstance(), CDefView::OnCreate(), and SHGetNameAndFlagsW().

◆ SHGetComputerDisplayNameW()

EXTERN_C HRESULT WINAPI SHGetComputerDisplayNameW ( _In_opt_ PWSTR  pszServerName,
_In_ DWORD  dwFlags,
_Out_writes_z_(cchNameMax) PWSTR  pszName,
_In_ DWORD  cchNameMax 
)

Definition at line 2108 of file utils.cpp.

2113{
2114 WCHAR szDesc[256], szCompName[MAX_COMPUTERNAME_LENGTH + 1];
2115
2116 // If no server name is specified, retrieve the local computer name
2117 if (!pszServerName)
2118 {
2119 // Use computer name as server name
2120 DWORD cchCompName = _countof(szCompName);
2121 if (!GetComputerNameW(szCompName, &cchCompName))
2122 return E_FAIL;
2123 pszServerName = szCompName;
2124
2125 // Don't use the cache for the local machine
2127 }
2128
2129 // Get computer description from cache if necessary
2130 HRESULT hr = E_FAIL;
2131 if (!(dwFlags & SHGCDN_NOCACHE))
2132 hr = SHELL_GetCachedComputerDescription(szDesc, _countof(szDesc), pszServerName);
2133
2134 // Actually retrieve the computer description if it is not in the cache
2135 if (FAILED(hr))
2136 {
2137 hr = SHELL_GetComputerDescription(szDesc, _countof(szDesc), pszServerName);
2138 if (FAILED(hr))
2139 szDesc[0] = UNICODE_NULL;
2140
2141 // Cache the description if necessary
2142 if (!(dwFlags & SHGCDN_NOCACHE))
2143 SHELL_CacheComputerDescription(pszServerName, szDesc);
2144 }
2145
2146 // If getting the computer description failed, store the server name only
2147 if (FAILED(hr) || !szDesc[0])
2148 {
2150 return hr; // Bail out if no server name is requested
2151
2152 StringCchCopyW(pszName, cchNameMax, SHELL_SkipServerSlashes(pszServerName));
2153 return S_OK;
2154 }
2155
2156 // If no server name is requested, store the description only
2158 {
2159 StringCchCopyW(pszName, cchNameMax, szDesc);
2160 return S_OK;
2161 }
2162
2163 // Build a string like "Description (SERVERNAME)"
2164 return SHELL_BuildDisplayMachineName(pszName, cchNameMax, pszServerName, szDesc);
2165}
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
static HRESULT SHELL_GetComputerDescription(_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ SIZE_T cchDescMax, _In_ PWSTR pszServerName)
Definition: utils.cpp:2065
static HRESULT SHELL_BuildDisplayMachineName(_Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax, _In_ PCWSTR pszServerName, _In_ PCWSTR pszDescription)
Definition: utils.cpp:2088
static VOID SHELL_CacheComputerDescription(_In_ PCWSTR pszServerName, _In_ PCWSTR pszDesc)
Definition: utils.cpp:2051
static HRESULT SHELL_GetCachedComputerDescription(_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ DWORD cchDescMax, _In_ PCWSTR pszServerName)
Definition: utils.cpp:2038
#define SHGCDN_NOSERVERNAME
Definition: undocshell.h:1066
#define SHGCDN_NOCACHE
Definition: undocshell.h:1065
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:267

◆ SHGetNameAndFlagsW()

HRESULT SHGetNameAndFlagsW ( _In_ LPCITEMIDLIST  pidl,
_In_ DWORD  dwFlags,
_Out_opt_ LPWSTR  pszText,
_In_ UINT  cchBuf,
_Inout_opt_ DWORD pdwAttributes 
)

Definition at line 575 of file utils.cpp.

581{
582 if (pszText)
583 *pszText = UNICODE_NULL;
584
586
587 CComPtr<IShellFolder> psfFolder;
588 LPCITEMIDLIST ppidlLast;
589 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfFolder), &ppidlLast);
590 if (SUCCEEDED(hr))
591 {
592 if (pszText)
593 hr = DisplayNameOfW(psfFolder, ppidlLast, dwFlags, pszText, cchBuf);
594
595 if (SUCCEEDED(hr))
596 {
597 if (pdwAttributes)
598 *pdwAttributes = SHGetAttributes(psfFolder, ppidlLast, *pdwAttributes);
599 }
600 }
601
602 if (SUCCEEDED(hrCoInit))
604
605 return hr;
606}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:520
EXTERN_C HRESULT WINAPI DisplayNameOfW(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
Definition: utils.cpp:504
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:566

Referenced by CDrvDefExt::AddMainPage(), DoGetFileTitle(), CShellLink::OnInitDialog(), SHELL_execute(), SHELL_GetCaptionFromDataObject(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ SHGetPathCchFromIDListW()

EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW ( LPCITEMIDLIST  pidl,
LPWSTR  pszPath,
SIZE_T  cchPathMax 
)

◆ SHGetRealIDL()

EXTERN_C HRESULT WINAPI SHGetRealIDL ( _In_ IShellFolder psf,
_In_ PCUITEMID_CHILD  pidlSimple,
_Outptr_ PITEMID_CHILD ppidlReal 
)

Definition at line 1715 of file utils.cpp.

1719{
1720 HRESULT hr;
1721 STRRET strret;
1723 SFGAOF attrs;
1724
1725 *ppidlReal = NULL;
1726
1727 hr = IShellFolder_GetDisplayNameOf(psf, pidlSimple, SHGDN_INFOLDER | SHGDN_FORPARSING,
1728 &strret, 0);
1730 return hr;
1731
1732 hr = StrRetToBufW(&strret, pidlSimple, szPath, _countof(szPath));
1734 return hr;
1735
1736 attrs = SFGAO_FILESYSTEM;
1737 hr = psf->GetAttributesOf(1, &pidlSimple, &attrs);
1738 if (SUCCEEDED(hr) && !(attrs & SFGAO_FILESYSTEM))
1739 return SHILClone(pidlSimple, ppidlReal);
1740
1741 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, szPath, NULL, ppidlReal, NULL);
1742 if (hr == E_INVALIDARG || hr == E_NOTIMPL)
1743 return SHILClone(pidlSimple, ppidlReal);
1744
1745 return hr;
1746}
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:215
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83

Referenced by CDefView::OnChangeNotify().

◆ SHGetShellStyleHInstance()

EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance ( VOID  )

Definition at line 933 of file utils.cpp.

934{
937 HRESULT hr;
938 CStringW strShellStyle;
939
940 TRACE("SHGetShellStyleHInstance called\n");
941
942 /* First, attempt to load the shellstyle dll from the current active theme */
944 if (FAILED(hr))
945 goto DoDefault;
946
947 /* Strip the theme filename */
949
950 strShellStyle = szPath;
951 strShellStyle += L"\\Shell\\";
952 strShellStyle += szColorName;
953 strShellStyle += L"\\ShellStyle.dll";
954
956 if (hInst)
957 return hInst;
958
959 /* Otherwise, use the version stored in the System32 directory */
960DoDefault:
961 if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
963 {
964 ERR("Expand failed\n");
965 return NULL;
966 }
968}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:520
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1145
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:980
static const WCHAR szColorName[]
Definition: system.c:42
HINSTANCE hInst
Definition: dxdiag.c:13
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338

◆ SHGetUnreadMailCountW()

EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW ( _In_opt_ HKEY  hKeyUser,
_In_opt_ PCWSTR  pszMailAddress,
_Out_opt_ PDWORD  pdwCount,
_Inout_opt_ PFILETIME  pFileTime,
_Out_writes_opt_(cchShellExecuteCommand) PWSTR  pszShellExecuteCommand,
_In_ INT  cchShellExecuteCommand 
)

Definition at line 1026 of file utils.cpp.

1033{
1034 LSTATUS error;
1035 HKEY hKey;
1036
1037 if (!hKeyUser)
1038 hKeyUser = HKEY_CURRENT_USER;
1039
1040 if (pszMailAddress)
1041 {
1042 CStringW strKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail";
1043 strKey += L'\\';
1044 strKey += pszMailAddress;
1045
1046 error = RegOpenKeyExW(hKeyUser, strKey, 0, KEY_QUERY_VALUE, &hKey);
1047 if (error)
1048 return HRESULT_FROM_WIN32(error);
1049
1050 error = SHELL_ReadSingleUnreadMailCount(hKey, pdwCount, pFileTime,
1051 pszShellExecuteCommand, cchShellExecuteCommand);
1052 }
1053 else
1054 {
1055 if (pszShellExecuteCommand || cchShellExecuteCommand)
1056 return E_INVALIDARG;
1057
1058 *pdwCount = 0;
1059
1060 error = RegOpenKeyExW(hKeyUser, L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail",
1062 if (error)
1063 return HRESULT_FROM_WIN32(error);
1064
1065 for (DWORD dwIndex = 0; !error; ++dwIndex)
1066 {
1067 WCHAR Name[2 * MAX_PATH];
1069 FILETIME LastWritten;
1070 error = RegEnumKeyExW(hKey, dwIndex, Name, &cchName, NULL, NULL, NULL, &LastWritten);
1071 if (error)
1072 break;
1073
1074 HKEY hSubKey;
1075 error = RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey);
1076 if (error)
1077 break;
1078
1079 FILETIME FileTime;
1080 DWORD dwCount;
1081 error = SHELL_ReadSingleUnreadMailCount(hSubKey, &dwCount, &FileTime, NULL, 0);
1082 if (!error && (!pFileTime || CompareFileTime(&FileTime, pFileTime) >= 0))
1083 *pdwCount += dwCount;
1084
1085 RegCloseKey(hSubKey);
1086 }
1087
1090 }
1091
1093
1094 return error ? HRESULT_FROM_WIN32(error) : S_OK;
1095}
LPWSTR Name
Definition: desk.c:124
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
static DWORD SHELL_ReadSingleUnreadMailCount(_In_ HKEY hKey, _Out_opt_ PDWORD pdwCount, _Out_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) LPWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
Definition: utils.cpp:982
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2521

Referenced by START_TEST().

◆ SHGetUserDisplayName()

EXTERN_C HRESULT WINAPI SHGetUserDisplayName ( _Out_writes_to_ *, *puSize PWSTR  pName,
_Inout_ PULONG  puSize 
)

Definition at line 1967 of file utils.cpp.

1970{
1971 if (!pName || !puSize)
1972 return E_INVALIDARG;
1973
1974 if (GetUserNameExW(NameDisplay, pName, puSize))
1975 return S_OK;
1976
1977 LONG error = GetLastError(); // for ERROR_NONE_MAPPED
1979
1980 WCHAR UserName[MAX_PATH];
1981 DWORD cchUserName = _countof(UserName);
1982 if (!GetUserNameW(UserName, &cchUserName))
1984
1985 // Was the user name not available in the specified format (NameDisplay)?
1986 if (error == ERROR_NONE_MAPPED)
1987 {
1988 // Try to get the user name by using Network API
1989 PUSER_INFO_2 UserInfo;
1990 DWORD NetError = NetUserGetInfo(NULL, UserName, 2, (PBYTE*)&UserInfo);
1991 if (NetError)
1992 {
1993 hr = HRESULT_FROM_WIN32(NetError);
1994 }
1995 else
1996 {
1997 if (UserInfo->usri2_full_name)
1998 {
1999 hr = StringCchCopyW(pName, *puSize, UserInfo->usri2_full_name);
2000 if (SUCCEEDED(hr))
2001 {
2002 // Include the NUL-terminator
2003 *puSize = lstrlenW(UserInfo->usri2_full_name) + 1;
2004 }
2005 }
2006
2007 NetApiBufferFree(UserInfo);
2008 }
2009 }
2010
2011 if (FAILED(hr))
2012 {
2013 hr = StringCchCopyW(pName, *puSize, UserName);
2014 if (SUCCEEDED(hr))
2015 *puSize = cchUserName;
2016 }
2017
2018 return hr;
2019}
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3147
static LPSTR pName
Definition: security.c:116
long LONG
Definition: pedump.c:60
BOOLEAN WINAPI GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
Definition: sspi.c:1079
LPWSTR usri2_full_name
Definition: lmaccess.h:222
#define ERROR_NONE_MAPPED
Definition: winerror.h:1159

Referenced by START_TEST().

◆ SHGetUserSessionId()

EXTERN_C DWORD WINAPI SHGetUserSessionId ( _In_opt_ HANDLE  hToken)

Definition at line 788 of file utils.cpp.

789{
790 DWORD dwSessionId, dwLength;
791 BOOL bOpenToken = FALSE;
792
793 TRACE("%p\n", hToken);
794
795 if (!hToken)
796 bOpenToken = SHOpenEffectiveToken(&hToken);
797
798 if (!hToken ||
799 !GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
800 {
801 dwSessionId = 0;
802 }
803
804 if (bOpenToken)
805 CloseHandle(hToken);
806
807 return dwSessionId;
808}
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
#define CloseHandle
Definition: compat.h:739
static DWORD DWORD * dwLength
Definition: fusion.c:86
EXTERN_C BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken)
Definition: utils.cpp:779
@ TokenSessionId
Definition: setypes.h:989

◆ SHILAppend()

HRESULT SHILAppend ( _Inout_ LPITEMIDLIST  pidl,
_Inout_ LPITEMIDLIST ppidl 
)

Definition at line 275 of file utils.cpp.

276{
277 LPITEMIDLIST pidlOld = *ppidl;
278 if (!pidlOld)
279 {
280 *ppidl = pidl;
281 return S_OK;
282 }
283
284 HRESULT hr = SHILCombine(*ppidl, pidl, ppidl);
285 ILFree(pidlOld);
286 ILFree(pidl);
287 return hr;
288}

Referenced by CFSFolder::_ParseSimple(), BrFolder_Treeview_Rename(), and CFSFolder::ParseDisplayName().

◆ SHILClone()

◆ SHInvokePrivilegedFunctionW()

EXTERN_C HRESULT WINAPI SHInvokePrivilegedFunctionW ( _In_ LPCWSTR  pszName,
_In_ PRIVILEGED_FUNCTION  fn,
_In_opt_ LPARAM  lParam 
)

Definition at line 815 of file utils.cpp.

819{
820 TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
821
822 if (!pszName || !fn)
823 return E_INVALIDARG;
824
825 HANDLE hToken = NULL;
826 TOKEN_PRIVILEGES NewPriv, PrevPriv;
827 BOOL bAdjusted = FALSE;
828
829 if (SHOpenEffectiveToken(&hToken) &&
830 ::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
831 {
832 NewPriv.PrivilegeCount = 1;
834
835 DWORD dwReturnSize;
836 bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
837 sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
838 }
839
840 HRESULT hr = fn(lParam);
841
842 if (bAdjusted)
843 ::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
844
845 if (hToken)
846 ::CloseHandle(hToken);
847
848 return hr;
849}
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
$ULONG PrivilegeCount
Definition: setypes.h:1035
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1036
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

◆ SHIsBadInterfacePtr()

EXTERN_C BOOL WINAPI SHIsBadInterfacePtr ( _In_ LPCVOID  pv,
_In_ UINT_PTR  ucb 
)

Definition at line 1943 of file utils.cpp.

1946{
1947 struct CUnknownVtbl
1948 {
1952 };
1953 struct CUnknown { CUnknownVtbl *lpVtbl; };
1954 const CUnknown *punk = reinterpret_cast<const CUnknown *>(pv);
1955 return !punk || IsBadReadPtr(punk, sizeof(punk->lpVtbl)) ||
1956 IsBadReadPtr(punk->lpVtbl, ucb) ||
1957 IsBadCodePtr((FARPROC)punk->lpVtbl->Release);
1958}
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
_In_ BOOLEAN Release
Definition: cdrom.h:920
int(* FARPROC)()
Definition: compat.h:36
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:872
static HRESULT QueryInterface(REFIID, void **)
Definition: events.c:2587
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:83
#define REFIID
Definition: guiddef.h:118
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7

Referenced by START_TEST().

◆ SHIsFileSysBindCtx()

HRESULT SHIsFileSysBindCtx ( _In_ IBindCtx pBindCtx,
_Out_opt_ WIN32_FIND_DATAW pFindData 
)

Definition at line 375 of file utils.cpp.

376{
379
380 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam((LPWSTR)STR_FILE_SYS_BIND_DATA, &punk)))
381 return S_FALSE;
382
384 return S_FALSE;
385
386 if (pFindData)
387 pBindData->GetFindData(pFindData);
388
389 return S_OK;
390}

Referenced by CDesktopFolder::ParseDisplayName(), CDrivesFolder::ParseDisplayName(), and CFSFolder::ParseDisplayName().

◆ SHLoadPopupMenu()

static HMENU SHLoadPopupMenu ( HINSTANCE  hInstance,
UINT  uMenuId 
)
static

Definition at line 61 of file utils.cpp.

62{
63 HMENU hMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(uMenuId));
64 if (!hMenu)
65 return NULL;
66 HMENU hSubMenu = GetSubMenu(hMenu, 0);
67 RemoveMenu(hMenu, 0, MF_BYPOSITION);
68 DestroyMenu(hMenu);
69 return hSubMenu;
70}
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)

Referenced by CDefFolderMenu_MergeMenu().

◆ SHOpenEffectiveToken()

EXTERN_C BOOL WINAPI SHOpenEffectiveToken ( _Out_ LPHANDLE  phToken)

Definition at line 779 of file utils.cpp.

780{
781 TRACE("%p\n", phToken);
783}
static BOOL OpenEffectiveToken(_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
Definition: utils.cpp:321
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:942
#define TOKEN_QUERY
Definition: setypes.h:940

Referenced by SHGetUserSessionId(), SHInvokePrivilegedFunctionW(), and SHTestTokenPrivilegeW().

◆ ShortSizeFormatW()

EXTERN_C LPWSTR WINAPI ShortSizeFormatW ( _In_ DWORD  dwNumber,
_Out_writes_(0x8FFF) LPWSTR  pszBuffer 
)

Definition at line 768 of file utils.cpp.

771{
772 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
773 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
774}
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2524

◆ SHSetFolderPathA()

EXTERN_C HRESULT WINAPI SHSetFolderPathA ( _In_ INT  csidl,
_In_ HANDLE  hToken,
_In_ DWORD  dwFlags,
_In_ LPCSTR  pszPath 
)

Definition at line 715 of file utils.cpp.

720{
721 TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
722 CStringW strPathW(pszPath);
723 return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
724}
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:714

◆ SHSetLocalizedName()

EXTERN_C HRESULT WINAPI SHSetLocalizedName ( _In_ PCWSTR  pszPath,
_In_ PCWSTR  pszResModule,
_In_ INT  idsRes 
)

Definition at line 2272 of file utils.cpp.

2276{
2277 HRESULT hr;
2278 IShellFolder *pDesktop = NULL, *pParent = NULL;
2279 LPITEMIDLIST pidl = NULL;
2280 LPCITEMIDLIST pidlLast;
2282 INT cchShortMax, cchShort, cchName;
2283 PWSTR pszShortPath = NULL, pszName = NULL;
2284
2287 return hr;
2288
2289 hr = SHGetDesktopFolder(&pDesktop);
2291 goto Cleanup;
2292
2293 hr = pDesktop->ParseDisplayName(NULL, NULL, (PWSTR)pszPath, NULL, &pidl, NULL);
2295 goto Cleanup;
2296
2297 hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &pParent), &pidlLast);
2299 goto Cleanup;
2300
2302 cchShortMax = lstrlenW(pszResModule) + 1;
2303 pszShortPath = (PWSTR)HeapAlloc(hProcessHeap, 0, cchShortMax * sizeof(WCHAR));
2304 if (!pszShortPath)
2305 {
2306 hr = E_OUTOFMEMORY;
2307 goto Cleanup;
2308 }
2309
2310 cchShort = GetShortPathNameW(pszResModule, pszShortPath, cchShortMax);
2311 if (cchShort)
2312 pszResModule = pszShortPath;
2313 else
2314 cchShort = cchShortMax;
2315
2316 /* 14 == '@' + ',' + '-' + (digits of max width 10) + NUL */
2317 cchName = cchShort + 14;
2318 pszName = (PWSTR)HeapAlloc(hProcessHeap, 0, cchName * sizeof(WCHAR));
2319 if (!pszName)
2320 {
2321 hr = E_OUTOFMEMORY;
2322 goto Cleanup;
2323 }
2324
2325 wnsprintfW(pszName, cchName, L"@%s,%d", pszResModule, -idsRes);
2326 hr = pParent->SetNameOf(NULL, pidlLast, pszName, 0, NULL);
2327
2328Cleanup:
2329 if (pszName)
2330 HeapFree(hProcessHeap, 0, pszName);
2331 if (pszShortPath)
2332 HeapFree(hProcessHeap, 0, pszShortPath);
2333 if (pParent)
2334 pParent->Release();
2335 if (pidl)
2336 SHFree(pidl);
2337 if (pDesktop)
2338 pDesktop->Release();
2340 return hr;
2341}
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1752
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370
int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt,...)
Definition: wsprintf.c:564
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE hProcessHeap
Definition: explorer.cpp:25
FxObject * pParent
Definition: fxdpcapi.cpp:86
HRESULT ParseDisplayName([in] HWND hwndOwner, [in] LPBC pbcReserved, [in, string] LPOLESTR lpszDisplayName, [out] ULONG *pchEaten, [out] PIDLIST_RELATIVE *ppidl, [in, out, unique] ULONG *pdwAttributes)
uint16_t * PWSTR
Definition: typedefs.h:56

◆ SHSetUnreadMailCountW()

EXTERN_C HRESULT WINAPI SHSetUnreadMailCountW ( _In_ PCWSTR  pszMailAddress,
_In_ DWORD  dwCount,
_In_ PCWSTR  pszShellExecuteCommand 
)

Definition at line 1104 of file utils.cpp.

1108{
1109 CString strKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\";
1110 strKey += pszMailAddress;
1111
1112 HKEY hKey;
1113 DWORD dwDisposition;
1115 &hKey, &dwDisposition);
1116 if (error)
1117 return HRESULT_FROM_WIN32(error);
1118
1119 error = RegSetValueExW(hKey, L"MessageCount", 0, REG_DWORD, (PBYTE)&dwCount, sizeof(dwCount));
1120 if (error)
1121 {
1123 return HRESULT_FROM_WIN32(error);
1124 }
1125
1126 FILETIME FileTime;
1127 GetSystemTimeAsFileTime(&FileTime);
1128
1129 error = RegSetValueExW(hKey, L"TimeStamp", 0, REG_BINARY, (PBYTE)&FileTime, sizeof(FileTime));
1130 if (error)
1131 {
1133 return HRESULT_FROM_WIN32(error);
1134 }
1135
1136 WCHAR szBuff[2 * MAX_PATH];
1137 if (!PathUnExpandEnvStringsW(pszShellExecuteCommand, szBuff, _countof(szBuff)))
1138 {
1139 HRESULT hr = StringCchCopyW(szBuff, _countof(szBuff), pszShellExecuteCommand);
1141 {
1143 return hr;
1144 }
1145 }
1146
1147 DWORD cbValue = (lstrlenW(szBuff) + 1) * sizeof(WCHAR);
1148 error = RegSetValueExW(hKey, L"Application", 0, REG_SZ, (PBYTE)szBuff, cbValue);
1149
1151 return (error ? HRESULT_FROM_WIN32(error) : S_OK);
1152}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI PathUnExpandEnvStringsW(const WCHAR *path, WCHAR *buffer, UINT buf_len)
Definition: path.c:2705
#define KEY_SET_VALUE
Definition: nt_native.h:1020

Referenced by START_TEST().

◆ SHShouldShowWizards()

EXTERN_C HRESULT WINAPI SHShouldShowWizards ( _In_ IUnknown pUnknown)

Definition at line 298 of file utils.cpp.

299{
300 HRESULT hr;
301 IShellBrowser *pBrowser;
302
303 hr = IUnknown_QueryService(pUnknown, SID_STopWindow, IID_PPV_ARG(IShellBrowser, &pBrowser));
304 if (FAILED(hr))
305 return hr;
306
309 if (state.fWebView &&
310 !SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
311 L"ShowWizardsTEST", FALSE, FALSE))
312 {
313 hr = S_FALSE;
314 }
315
316 pBrowser->Release();
317 return hr;
318}
static int state
Definition: maze.c:121
BOOL WINAPI SHRegGetBoolUSValueW(const WCHAR *subkey, const WCHAR *value, BOOL ignore_hkcu, BOOL default_value)
Definition: registry.c:4139
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1501
VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
Definition: shellord.c:225
#define SSF_WEBVIEW
Definition: shlobj.h:1627

Referenced by START_TEST().

◆ SHSkipJunctionBinding()

BOOL SHSkipJunctionBinding ( _In_ IBindCtx pbc,
_In_ CLSID pclsid 
)

Definition at line 363 of file utils.cpp.

364{
365 if (!pbc)
366 return FALSE;
367
368 BIND_OPTS BindOps = { sizeof(BindOps) };
369 if (SUCCEEDED(pbc->GetBindOptions(&BindOps)) && BindOps.grfFlags == OLECONTF_LINKS)
370 return TRUE;
371
372 return pclsid && SHSkipJunction(pbc, pclsid);
373}
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4779

Referenced by CDesktopFolder::_ParseDisplayNameByParent().

◆ SHStartNetConnectionDialogA()

EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogA ( _In_ HWND  hwnd,
_In_ LPCSTR  pszRemoteName,
_In_ DWORD  dwType 
)

Definition at line 1575 of file utils.cpp.

1579{
1580 LPCWSTR pszRemoteNameW = NULL;
1581 CStringW strRemoteNameW;
1582
1583 TRACE("(%p, %s, %lu)\n", hwnd, debugstr_a(pszRemoteName), dwType);
1584
1585 if (pszRemoteName)
1586 {
1587 strRemoteNameW = pszRemoteName;
1588 pszRemoteNameW = strRemoteNameW;
1589 }
1590
1591 return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType);
1592}
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:457

Referenced by SHStartNetConnectionDialog().

◆ SHTestTokenPrivilegeW()

EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW ( _In_opt_ HANDLE  hToken,
_In_ LPCWSTR  lpName 
)

Definition at line 858 of file utils.cpp.

861{
862 LUID Luid;
864 PTOKEN_PRIVILEGES pTokenPriv;
865 HANDLE hNewToken = NULL;
866 BOOL ret = FALSE;
867
868 TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
869
870 if (!lpName)
871 return FALSE;
872
873 if (!hToken)
874 {
875 if (!SHOpenEffectiveToken(&hNewToken))
876 goto Quit;
877
878 if (!hNewToken)
879 return FALSE;
880
881 hToken = hNewToken;
882 }
883
884 if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
885 return FALSE;
886
887 dwLength = 0;
889 goto Quit;
890
892 if (!pTokenPriv)
893 goto Quit;
894
895 if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
896 {
897 UINT iPriv, cPrivs;
898 cPrivs = pTokenPriv->PrivilegeCount;
899 for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
900 {
901 ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
902 }
903 }
904
905 LocalFree(pTokenPriv);
906
907Quit:
908 if (hToken == hNewToken)
909 CloseHandle(hNewToken);
910
911 return ret;
912}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define LPTR
Definition: minwinbase.h:93
_In_ LPCSTR lpName
Definition: winbase.h:2543
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:304
@ TokenPrivileges
Definition: setypes.h:980
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES

Referenced by IsShutdownAllowed().

◆ StrEndNA()

static PCSTR StrEndNA ( _In_ PCSTR  psz,
_In_ INT_PTR  cch 
)
static

Definition at line 17 of file utils.cpp.

18{
19 PCSTR pch, pchEnd = &psz[cch];
20 for (pch = psz; *pch && pch < pchEnd; pch = CharNextA(pch))
21 ;
22 if (pchEnd < pch) // A double-byte character detected at last?
23 pch -= 2; // The width of a double-byte character is 2
24 return pch;
25}
LPSTR WINAPI CharNextA(const char *ptr)
Definition: string.c:1107
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
const char * PCSTR
Definition: typedefs.h:52

Referenced by StrRStrA().

◆ StrEndNW()

static PCWSTR StrEndNW ( _In_ PCWSTR  psz,
_In_ INT_PTR  cch 
)
static

Definition at line 27 of file utils.cpp.

28{
29 PCWSTR pch, pchEnd = &psz[cch];
30 for (pch = psz; *pch && pch < pchEnd; ++pch)
31 ;
32 return pch;
33}

Referenced by StrRStrW().

◆ StrRStrA()

EXTERN_C PSTR WINAPI StrRStrA ( _In_ PCSTR  pszSrc,
_In_opt_ PCSTR  pszLast,
_In_ PCSTR  pszSearch 
)

Definition at line 122 of file utils.cpp.

126{
127 INT cchSearch = lstrlenA(pszSearch);
128
129 PCSTR pchEnd = pszLast ? pszLast : &pszSrc[lstrlenA(pszSrc)];
130 if (pchEnd == pszSrc)
131 return NULL;
132
133 INT_PTR cchEnd = pchEnd - pszSrc;
134 for (;;)
135 {
136 --pchEnd;
137 --cchEnd;
138 if (!pchEnd)
139 break;
140 if (!StrCmpNA(pchEnd, pszSearch, cchSearch) && pchEnd == StrEndNA(pszSrc, cchEnd))
141 break;
142 if (pchEnd == pszSrc)
143 return NULL;
144 }
145
146 return const_cast<PSTR>(pchEnd);
147}
INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
Definition: string.c:489
static PCSTR StrEndNA(_In_ PCSTR psz, _In_ INT_PTR cch)
Definition: utils.cpp:17
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
int32_t INT_PTR
Definition: typedefs.h:64
char * PSTR
Definition: typedefs.h:51

Referenced by TEST_StrRStrA().

◆ StrRStrW()

EXTERN_C PWSTR WINAPI StrRStrW ( _In_ PCWSTR  pszSrc,
_In_opt_ PCWSTR  pszLast,
_In_ PCWSTR  pszSearch 
)

Definition at line 154 of file utils.cpp.

158{
159 INT cchSearch = lstrlenW(pszSearch);
160
161 PCWSTR pchEnd = pszLast ? pszLast : &pszSrc[lstrlenW(pszSrc)];
162 if (pchEnd == pszSrc)
163 return NULL;
164
165 INT_PTR cchEnd = pchEnd - pszSrc;
166 for (;;)
167 {
168 --pchEnd;
169 --cchEnd;
170 if (!pchEnd)
171 break;
172 if (!StrCmpNW(pchEnd, pszSearch, cchSearch) && pchEnd == StrEndNW(pszSrc, cchEnd))
173 break;
174 if (pchEnd == pszSrc)
175 return NULL;
176 }
177
178 return const_cast<PWSTR>(pchEnd);
179}
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:500
static PCWSTR StrEndNW(_In_ PCWSTR psz, _In_ INT_PTR cch)
Definition: utils.cpp:27

Referenced by TEST_StrRStrW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ g_AliasTable

const ALIAS_MAPPING g_AliasTable[]
static
Initial value:
=
{
{
},
{
},
{
},
{
}
}
#define ALIAS_USER_FOLDER
Definition: shell32_main.h:119
#define ALIAS_DESKTOP
Definition: shell32_main.h:120
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2205
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2196
#define CSIDL_PERSONAL
Definition: shlobj.h:2186
#define CSIDL_FLAG_NO_ALIAS
Definition: shlobj.h:2241
#define CSIDL_DESKTOP
Definition: shlobj.h:2181
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2226

PIDL alias table.

Definition at line 2176 of file utils.cpp.

Referenced by SHELL32_ReparentAsAliasPidl().