ReactOS 0.4.15-dev-8434-g155a7c7
utils.cpp File Reference
#include "precomp.h"
Include dependency graph for utils.cpp:

Go to the source code of this file.

Classes

class  CDummyOleWindow
 

Macros

#define PATH_VALID_ELEMENT
 
#define COPY_STREAM_DEFAULT_BUFFER_SIZE   0x4000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
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)
 
static BOOL OpenEffectiveToken (_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
 
HRESULT Shell_TranslateIDListAlias (_In_ LPCITEMIDLIST pidl, _In_ HANDLE hToken, _Out_ LPITEMIDLIST *ppidlAlias, _In_ DWORD dwFlags)
 
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)
 
HRESULT Shell_DisplayNameOf (_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 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)
 
EXTERN_C LPSTR WINAPI SheRemoveQuotesA (LPSTR psz)
 
EXTERN_C LPWSTR WINAPI SheRemoveQuotesW (LPWSTR psz)
 
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 SHOpenPropSheetA (_In_opt_ LPCSTR pszCaption, _In_opt_ HKEY *ahKeys, _In_ UINT cKeys, _In_ const CLSID *pclsidDefault, _In_ IDataObject *pDataObject, _In_opt_ IShellBrowser *pShellBrowser, _In_opt_ LPCSTR pszStartPage)
 
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)
 

Macro Definition Documentation

◆ 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:4326
#define PATH_CHAR_CLASS_SPACE
Definition: path.c:4325
#define PATH_CHAR_CLASS_SEMICOLON
Definition: path.c:4323
#define PATH_CHAR_CLASS_COMMA
Definition: path.c:4324
#define PATH_CHAR_CLASS_DOT
Definition: path.c:4320

Definition at line 33 of file utils.cpp.

Function Documentation

◆ Activate_RunDLL()

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

Definition at line 1094 of file utils.cpp.

1099{
1100 DWORD dwProcessID;
1101
1105 UNREFERENCED_PARAMETER(cmdshow);
1106
1107 TRACE("(%p, %p, %s, %d)\n", hwnd, hinst, debugstr_w(cmdline), cmdline);
1108
1110 return AllowSetForegroundWindow(dwProcessID);
1111}
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:317
#define TRACE(s)
Definition: solgame.cpp:4
TCHAR * cmdline
Definition: stretchblt.cpp:32
HWND WINAPI GetShellWindow(VOID)
Definition: desktop.c:651
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
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 120 of file utils.cpp.

121{
123 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
124 return FALSE;
125 return TRUE;
126}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FAILED(hr)
Definition: intsafe.h:51
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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

◆ BindCtx_GetMode()

DWORD BindCtx_GetMode ( _In_ IBindCtx pbc,
_In_ DWORD  dwDefault 
)

Definition at line 128 of file utils.cpp.

129{
130 if (!pbc)
131 return dwDefault;
132
133 BIND_OPTS BindOpts = { sizeof(BindOpts) };
134 HRESULT hr = pbc->GetBindOptions(&BindOpts);
135 if (FAILED(hr))
136 return dwDefault;
137
138 return BindOpts.grfMode;
139}
HRESULT hr
Definition: shlfolder.c:183

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

◆ BindCtx_GetUIWindow()

EXTERN_C HWND BindCtx_GetUIWindow ( _In_ IBindCtx pBindCtx)

Definition at line 323 of file utils.cpp.

324{
325 HWND hWnd = NULL;
326
328 if (pBindCtx && SUCCEEDED(pBindCtx->GetObjectParam((LPWSTR)L"UI During Binding", &punk)))
329 IUnknown_GetWindow(punk, &hWnd);
330
331 return hWnd;
332}
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1332
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define L(x)
Definition: ntvdm.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 383 of file utils.cpp.

388{
389 HRESULT hr = S_OK;
391
392 *ppbc = pBindCtx;
393
394 if (pBindCtx)
395 {
396 pBindCtx->AddRef();
397 }
398 else
399 {
400 hr = CreateBindCtx(0, ppbc);
401 if (FAILED(hr))
402 return hr;
403 }
404
405 if (!punk)
406 punk = pUnknown = new CDummyOleWindow();
407
408 hr = (*ppbc)->RegisterObjectParam(pszKey, punk);
409
410 if (pUnknown)
411 pUnknown->Release();
412
413 if (FAILED(hr))
414 {
415 (*ppbc)->Release();
416 *ppbc = NULL;
417 }
418
419 return hr;
420}
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
ULONG Release()
#define S_OK
Definition: intsafe.h:52
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556

Referenced by SHParseDisplayName().

◆ CopyStreamUI()

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

Definition at line 938 of file utils.cpp.

943{
944 HRESULT hr = E_FAIL;
945 DWORD cbBuff, cbRead, dwSizeToWrite;
946 DWORDLONG cbDone;
947 LPVOID pBuff;
948 CComHeapPtr<BYTE> pHeapPtr;
949 STATSTG Stat;
950 BYTE abBuff[1024];
951
952 TRACE("(%p, %p, %p, %I64u)\n", pSrc, pDst, pProgress, dwlSize);
953
954 if (dwlSize == 0) // Invalid size?
955 {
956 // Get the stream size
957 ZeroMemory(&Stat, sizeof(Stat));
958 if (FAILED(pSrc->Stat(&Stat, STATFLAG_NONAME)))
959 pProgress = NULL; // No size info. Disable progress
960 else
961 dwlSize = Stat.cbSize.QuadPart;
962 }
963
964 if (!pProgress) // Progress is disabled?
965 {
966 ULARGE_INTEGER uliSize;
967
968 if (dwlSize > 0)
969 uliSize.QuadPart = dwlSize;
970 else
971 uliSize.HighPart = uliSize.LowPart = INVALID_FILE_SIZE;
972
973 return pSrc->CopyTo(pDst, uliSize, NULL, NULL); // One punch
974 }
975
976 // Allocate the buffer if necessary
977 if (dwlSize > 0 && dwlSize <= sizeof(abBuff))
978 {
979 cbBuff = sizeof(abBuff);
980 pBuff = abBuff;
981 }
982 else
983 {
984#define COPY_STREAM_DEFAULT_BUFFER_SIZE 0x4000
986 if (pHeapPtr.AllocateBytes(cbBuff))
987 {
988 pBuff = pHeapPtr;
989 }
990 else // Low memory?
991 {
992 cbBuff = sizeof(abBuff);
993 pBuff = abBuff;
994 }
995#undef COPY_STREAM_DEFAULT_BUFFER_SIZE
996 }
997
998 // Start reading
1000 zero.QuadPart = 0;
1001 pSrc->Seek(zero, 0, NULL);
1002 pDst->Seek(zero, 0, NULL);
1003 cbDone = 0;
1004 pProgress->SetProgress64(cbDone, dwlSize);
1005
1006 // Repeat reading and writing until goal
1007 for (;;)
1008 {
1009 hr = pSrc->Read(pBuff, cbBuff, &cbRead);
1010 if (FAILED(hr))
1011 break;
1012
1013 // Calculate the size to write
1014 if (dwlSize > 0)
1015 dwSizeToWrite = (DWORD)min((DWORDLONG)(dwlSize - cbDone), (DWORDLONG)cbRead);
1016 else
1017 dwSizeToWrite = cbRead;
1018
1019 if (dwSizeToWrite == 0) // No need to write?
1020 {
1021 hr = S_OK;
1022 break;
1023 }
1024
1025 hr = pDst->Write(pBuff, dwSizeToWrite, NULL);
1026 if (hr != S_OK)
1027 break;
1028
1029 cbDone += dwSizeToWrite;
1030
1031 if (pProgress->HasUserCancelled()) // Cancelled?
1032 {
1034 break;
1035 }
1036 pProgress->SetProgress64(cbDone, dwlSize);
1037
1038 if (dwlSize > 0 && cbDone >= dwlSize) // Reached the goal?
1039 {
1040 hr = S_OK;
1041 break;
1042 }
1043 }
1044
1045 return hr;
1046}
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 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:569
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:570
#define ZeroMemory
Definition: winbase.h:1712
#define INVALID_FILE_SIZE
Definition: winbase.h:548
#define ERROR_CANCELLED
Definition: winerror.h:726
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
unsigned char BYTE
Definition: xxhash.c:193

◆ DynamicPathCommonPrefixW()

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

Definition at line 1144 of file utils.cpp.

1148{
1149 SIZE_T cchPath1 = wcslen(lpszPath1);
1150 SIZE_T cchPath2 = wcslen(lpszPath2);
1151 LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16);
1152 INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath);
1153 strPath.ReleaseBuffer();
1154 return ret;
1155}
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2806
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
int ret

Referenced by PathIsEqualOrSubFolder().

◆ DynamicPathRemoveBackslashW()

static VOID DynamicPathRemoveBackslashW ( _Out_ CStringW strPath)
static

Definition at line 1216 of file utils.cpp.

1218{
1219 INT nLength = strPath.GetLength();
1220 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1221 strPath = strPath.Left(nLength - 1);
1222}
_In_ DWORD nLength
Definition: wincon.h:473

Referenced by PathIsEqualOrSubFolder().

◆ DynamicSHGetPathFromIDListW()

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

Definition at line 1161 of file utils.cpp.

1164{
1165 HRESULT hr;
1166
1167 for (UINT cchPath = MAX_PATH;; cchPath *= 2)
1168 {
1169 LPWSTR lpszPath = strPath.GetBuffer(cchPath);
1170 if (!lpszPath)
1171 return E_OUTOFMEMORY;
1172
1173 hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath);
1174 strPath.ReleaseBuffer();
1175
1177 break;
1178
1179 if (cchPath >= MAXUINT / 2)
1180 {
1181 hr = E_FAIL;
1182 break;
1183 }
1184 }
1185
1186 if (FAILED(hr))
1187 strPath.Empty();
1188
1189 return hr;
1190}
#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)
unsigned int UINT
Definition: ndis.h:50
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345

Referenced by DynamicSHGetSpecialFolderPathW().

◆ DynamicSHGetSpecialFolderPathW()

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

Definition at line 1193 of file utils.cpp.

1198{
1199 LPITEMIDLIST pidl;
1200 HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl);
1201 if (SUCCEEDED(hr))
1202 {
1203 hr = DynamicSHGetPathFromIDListW(pidl, strPath);
1204 CoTaskMemFree(pidl);
1205 }
1206
1207 if (FAILED(hr))
1208 strPath.Empty();
1209 else if (bCreate)
1210 CreateDirectoryW(strPath, NULL);
1211
1212 return hr;
1213}
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
static HRESULT DynamicSHGetPathFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
Definition: utils.cpp:1161
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3260
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1519
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 461 of file utils.cpp.

467{
468 TRACE("(%p, %s, %u, %p, %p)\n", hHandle, debugstr_a(lpFileName), wIndex, lpSize, lpIcon);
469
470 if (!lpFileName)
471 return 0;
472
473 CStringW strFileNameW(lpFileName);
474 return ExtractIconResInfoW(hHandle, strFileNameW, wIndex, lpSize, lpIcon);
475}
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:811
#define debugstr_a
Definition: kernel32.h:31
_In_ LPCSTR lpFileName
Definition: winbase.h:3071

◆ 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 1362 of file utils.cpp.

1363{
1364 HRESULT hr = pCM->GetCommandString(Id, GCS & ~GCS_UNICODE, NULL, Buf, cchMax);
1365 if (FAILED(hr))
1366 {
1368 hr = pCM->GetCommandString(Id, GCS | GCS_UNICODE, NULL, (LPSTR)buf, _countof(buf));
1369 if (SUCCEEDED(hr))
1370 hr = SHUnicodeToAnsi(buf, Buf, cchMax) > 0 ? S_OK : E_FAIL;
1371 }
1372 return hr;
1373}
DWORD Id
UINT cchMax
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2791
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _countof(array)
Definition: sndvol32.h:70
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetDfmCmd().

◆ GetDfmCmd()

UINT GetDfmCmd ( _In_ IContextMenu pCM,
_In_ LPCSTR  verba 
)

Definition at line 1376 of file utils.cpp.

1377{
1378 CHAR buf[MAX_PATH];
1379 if (IS_INTRESOURCE(verba))
1380 {
1381 if (FAILED(GetCommandStringA(pCM, LOWORD(verba), GCS_VERB, buf, _countof(buf))))
1382 return 0;
1383 verba = buf;
1384 }
1385 return MapVerbToDfmCmd(verba); // Returns DFM_CMD_* or 0
1386}
UINT MapVerbToDfmCmd(_In_ LPCSTR verba)
static HRESULT GetCommandStringA(_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
Definition: utils.cpp:1362
#define LOWORD(l)
Definition: pedump.c:82
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
char CHAR
Definition: xmlstorage.h:175

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 821 of file utils.cpp.

829{
830 WCHAR szBuff[20];
831
832 if (pSrc)
833 *pDest = *pSrc;
834 else
835 dwNumberFlags = 0;
836
837 if (!(dwNumberFlags & FMT_USE_NUMDIGITS))
838 {
840 pDest->NumDigits = StrToIntW(szBuff);
841 }
842
843 if (!(dwNumberFlags & FMT_USE_LEADZERO))
844 {
846 pDest->LeadingZero = StrToIntW(szBuff);
847 }
848
849 if (!(dwNumberFlags & FMT_USE_GROUPING))
850 {
852 pDest->Grouping = StrToIntW(szBuff);
853 }
854
855 if (!(dwNumberFlags & FMT_USE_DECIMAL))
856 {
857 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, pszDecimal, cchDecimal);
858 pDest->lpDecimalSep = pszDecimal;
859 }
860
861 if (!(dwNumberFlags & FMT_USE_THOUSAND))
862 {
863 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, pszThousand, cchThousand);
864 pDest->lpThousandSep = pszThousand;
865 }
866
867 if (!(dwNumberFlags & FMT_USE_NEGNUMBER))
868 {
870 pDest->NegativeOrder = StrToIntW(szBuff);
871 }
872}
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
#define LOCALE_USER_DEFAULT
#define FMT_USE_THOUSAND
Definition: undocshell.h:760
#define FMT_USE_GROUPING
Definition: undocshell.h:758
#define FMT_USE_NUMDIGITS
Definition: undocshell.h:756
#define FMT_USE_NEGNUMBER
Definition: undocshell.h:761
#define FMT_USE_LEADZERO
Definition: undocshell.h:757
#define FMT_USE_DECIMAL
Definition: undocshell.h:759
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_IDIGITS
Definition: winnls.h:45
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_INEGNUMBER
Definition: winnls.h:47
#define LOCALE_ILZERO
Definition: winnls.h:46

Referenced by Int64ToString().

◆ Int64ToStr()

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

Definition at line 776 of file utils.cpp.

780{
781 WCHAR szBuff[40];
782 UINT ich = 0, ichValue;
783#if (WINVER >= _WIN32_WINNT_VISTA)
784 BOOL bMinus = (llValue < 0);
785
786 if (bMinus)
787 llValue = -llValue;
788#endif
789
790 if (cchValue <= 0)
791 return E_FAIL;
792
793 do
794 {
795 szBuff[ich++] = (WCHAR)(L'0' + (llValue % 10));
796 llValue /= 10;
797 } while (llValue != 0 && ich < _countof(szBuff) - 1);
798
799#if (WINVER >= _WIN32_WINNT_VISTA)
800 if (bMinus && ich < _countof(szBuff))
801 szBuff[ich++] = '-';
802#endif
803
804 for (ichValue = 0; ich > 0 && ichValue < cchValue; ++ichValue)
805 {
806 --ich;
807 pszValue[ichValue] = szBuff[ich];
808 }
809
810 if (ichValue >= cchValue)
811 {
812 pszValue[cchValue - 1] = UNICODE_NULL;
813 return E_FAIL;
814 }
815
816 pszValue[ichValue] = UNICODE_NULL;
817 return S_OK;
818}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UNICODE_NULL

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 881 of file utils.cpp.

888{
889 INT ret;
890 NUMBERFMTW NumFormat;
891 WCHAR szValue[80], szDecimalSep[6], szThousandSep[6];
892
893 Int64ToStr(llValue, szValue, _countof(szValue));
894
895 if (bUseFormat)
896 {
897 Int64GetNumFormat(&NumFormat, pNumberFormat, dwNumberFlags,
898 szDecimalSep, _countof(szDecimalSep),
899 szThousandSep, _countof(szThousandSep));
900 ret = GetNumberFormatW(LOCALE_USER_DEFAULT, 0, szValue, &NumFormat, pszOut, cchOut);
901 if (ret)
902 --ret;
903 return ret;
904 }
905
906 if (FAILED(StringCchCopyW(pszOut, cchOut, szValue)))
907 return 0;
908
909 return lstrlenW(pszOut);
910}
#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:821
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:776
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212
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 1307 of file utils.cpp.

1314{
1315 if (!pEC)
1316 return E_INVALIDARG;
1317
1318 if (pSite)
1319 IUnknown_SetSite(pEC, pSite);
1320 IUnknown_InitializeCommand(pEC, pszCommandName, pPB);
1321
1323 if (pSIA && SUCCEEDED(pEC->QueryInterface(IID_PPV_ARG(IObjectWithSelection, &pOWS))))
1324 pOWS->SetSelection(pSIA);
1325
1326 DWORD dwKeyState = 0, fMask = pICI ? pICI->fMask : 0;
1327 pEC->SetNoShowUI((fMask & CMIC_MASK_FLAG_NO_UI) != 0);
1328 pEC->SetShowWindow(pICI ? pICI->nShow : SW_SHOW);
1329 if (fMask & CMIC_MASK_SHIFT_DOWN)
1330 dwKeyState |= MK_SHIFT;
1331 if (fMask & CMIC_MASK_CONTROL_DOWN)
1332 dwKeyState |= MK_CONTROL;
1333 pEC->SetKeyState(dwKeyState);
1334 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpDirectoryW)
1335 pEC->SetDirectory(pICI->lpDirectoryW);
1336 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpParametersW)
1337 pEC->SetParameters(pICI->lpParametersW);
1338 if (fMask & CMIC_MASK_PTINVOKE)
1339 pEC->SetPosition(pICI->ptInvoke);
1340
1341 HRESULT hr = pEC->Execute();
1342 if (pSite)
1343 IUnknown_SetSite(pEC, NULL);
1344 return hr;
1345}
#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:1294
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1407
#define MK_SHIFT
Definition: winuser.h:2369
#define MK_CONTROL
Definition: winuser.h:2370
#define SW_SHOW
Definition: winuser.h:775
#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 1348 of file utils.cpp.

1355{
1357 HRESULT hr = SHCreateShellItemArrayFromDataObject(pDO, IID_PPV_ARG(IShellItemArray, &pSIA));
1358 return SUCCEEDED(hr) ? InvokeIExecuteCommand(pEC, pszCommandName, pPB, pSIA, pICI, pSite) : hr;
1359}
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:1307

Referenced by CDefaultContextMenu::InvokeRegVerb().

◆ IsShutdownAllowed()

BOOL IsShutdownAllowed ( VOID  )

Definition at line 628 of file utils.cpp.

629{
631}
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
Definition: utils.cpp:572
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:384

Referenced by IsSuspendAllowed().

◆ IsSuspendAllowed()

BOOL WINAPI IsSuspendAllowed ( VOID  )

Definition at line 636 of file utils.cpp.

637{
638 TRACE("()\n");
640}
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:628
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488

◆ IUnknown_InitializeCommand()

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

Definition at line 1294 of file utils.cpp.

1298{
1299 HRESULT hr;
1301 if (SUCCEEDED(hr = pUnk->QueryInterface(IID_PPV_ARG(IInitializeCommand, &pIC))))
1302 hr = pIC->Initialize(pszCommandName, pPB);
1303 return hr;
1304}
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 919 of file utils.cpp.

926{
927 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
928 pNumberFormat, dwNumberFlags);
929}
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:881

Referenced by DoTestEntry(), and Test_LargeIntegerToString().

◆ OpenEffectiveToken()

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

Definition at line 89 of file utils.cpp.

92{
93 BOOL ret;
94
95 if (phToken == NULL)
96 {
98 return FALSE;
99 }
100
101 *phToken = NULL;
102
104 if (!ret && GetLastError() == ERROR_NO_TOKEN)
106
107 return ret;
108}
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:2658
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2715
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define ERROR_NO_TOKEN
Definition: winerror.h:587

Referenced by SHOpenEffectiveToken().

◆ PathIsDosDevice()

BOOL PathIsDosDevice ( _In_ LPCWSTR  pszName)

Definition at line 52 of file utils.cpp.

53{
57
58 if (lstrcmpiW(szPath, L"NUL") == 0 || lstrcmpiW(szPath, L"PRN") == 0 ||
59 lstrcmpiW(szPath, L"CON") == 0 || lstrcmpiW(szPath, L"AUX") == 0)
60 {
61 return TRUE;
62 }
63
64 if (_wcsnicmp(szPath, L"LPT", 3) == 0 || _wcsnicmp(szPath, L"COM", 3) == 0)
65 {
66 if ((L'0' <= szPath[3] && szPath[3] <= L'9') && szPath[4] == UNICODE_NULL)
67 return TRUE;
68 }
69
70 return FALSE;
71}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
LPCWSTR szPath
Definition: env.c:37
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)

Referenced by CFSFolder::_CreateIDListFromName().

◆ PathIsDotOrDotDotW()

BOOL PathIsDotOrDotDotW ( _In_ LPCWSTR  pszPath)

Definition at line 26 of file utils.cpp.

27{
28 if (pszPath[0] != L'.')
29 return FALSE;
30 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
31}

Referenced by PathIsValidElement().

◆ PathIsEqualOrSubFolder()

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

Definition at line 1229 of file utils.cpp.

1232{
1233 CStringW strCommon, strPath1;
1234
1235 TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2));
1236
1237 if (IS_INTRESOURCE(pszPath1OrCSIDL))
1238 {
1240 NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE);
1241 }
1242 else
1243 {
1244 strPath1 = pszPath1OrCSIDL;
1245 }
1246
1248
1249 if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon))
1250 return FALSE;
1251
1252 return strPath1.CompareNoCase(strCommon) == 0;
1253}
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1216
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1144
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1193
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2233

Referenced by PathIsTemporaryW(), and START_TEST().

◆ PathIsSlowA()

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

Definition at line 447 of file utils.cpp.

450{
451 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
452 CStringW strFileW(pszFile);
453 return PathIsSlowW(strFileW, dwAttr);
454}
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: stubs.cpp:934

◆ PathIsValidElement()

BOOL PathIsValidElement ( _In_ LPCWSTR  pszPath)

Definition at line 38 of file utils.cpp.

39{
40 if (!*pszPath || PathIsDotOrDotDotW(pszPath))
41 return FALSE;
42
43 for (LPCWSTR pch = pszPath; *pch; ++pch)
44 {
46 return FALSE;
47 }
48
49 return TRUE;
50}
#define PATH_VALID_ELEMENT
Definition: utils.cpp:33
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:26
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4419
#define pch(ap)
Definition: match.c:418
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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 220 of file utils.cpp.

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

Referenced by _BindToObject(), CDesktopFolder::_ParseDisplayNameByParent(), CGuidItemContextMenu_CreateInstance(), 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 187 of file utils.cpp.

193{
194 CComPtr<IShellFolder> psfDesktop;
195
196 *ppvObj = NULL;
197
198 if (!pShellFolder)
199 {
200 SHGetDesktopFolder(&psfDesktop);
201 if (!psfDesktop)
202 return E_FAIL;
203
204 pShellFolder = psfDesktop;
205 }
206
207 HRESULT hr;
208 if (_ILIsDesktop(pidl))
209 hr = pShellFolder->QueryInterface(riid, ppvObj);
210 else
211 hr = pShellFolder->BindToObject(pidl, pBindCtx, riid, ppvObj);
212
213 if (SUCCEEDED(hr) && !*ppvObj)
214 hr = E_FAIL;
215
216 return hr;
217}
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 280 of file utils.cpp.

281{
283 if (FAILED(hr))
285 return hr;
286}
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:280

Referenced by ShellExecuteExW(), and SHGetNameAndFlagsW().

◆ SHCreatePropertyBag()

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

Definition at line 689 of file utils.cpp.

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

◆ Shell_DisplayNameOf()

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

Definition at line 230 of file utils.cpp.

236{
237 *pszBuf = UNICODE_NULL;
238 STRRET sr;
239 HRESULT hr = psf->GetDisplayNameOf(pidl, dwFlags, &sr);
240 if (FAILED(hr))
241 return hr;
242 return StrRetToBufW(&sr, pidl, pszBuf, cchBuf);
243}
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by CFSDropTarget::_DoDrop(), and SHGetNameAndFlagsW().

◆ Shell_FailForceReturn()

BOOL Shell_FailForceReturn ( _In_ HRESULT  hr)

Definition at line 170 of file utils.cpp.

171{
173
174 switch (code)
175 {
178 case ERROR_CANCELLED:
179 return TRUE;
180
181 default:
183 }
184}
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
Definition: inflate.c:139
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define HRESULT_CODE(hr)
Definition: winerror.h:76
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159

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

◆ Shell_TranslateIDListAlias()

HRESULT Shell_TranslateIDListAlias ( _In_ LPCITEMIDLIST  pidl,
_In_ HANDLE  hToken,
_Out_ LPITEMIDLIST ppidlAlias,
_In_ DWORD  dwFlags 
)

Definition at line 111 of file utils.cpp.

116{
117 return E_FAIL; //FIXME
118}

Referenced by CDesktopFolder::ParseDisplayName().

◆ SheRemoveQuotesA()

EXTERN_C LPSTR WINAPI SheRemoveQuotesA ( LPSTR  psz)

Definition at line 699 of file utils.cpp.

700{
701 PCHAR pch;
702
703 if (*psz == '"')
704 {
705 for (pch = psz + 1; *pch && *pch != '"'; ++pch)
706 {
707 *(pch - 1) = *pch;
708 }
709
710 if (*pch == '"')
711 *(pch - 1) = ANSI_NULL;
712 }
713
714 return psz;
715}
#define ANSI_NULL
char * PCHAR
Definition: typedefs.h:51

◆ SheRemoveQuotesW()

EXTERN_C LPWSTR WINAPI SheRemoveQuotesW ( LPWSTR  psz)

Definition at line 724 of file utils.cpp.

725{
726 PWCHAR pch;
727
728 if (*psz == L'"')
729 {
730 for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
731 {
732 *(pch - 1) = *pch;
733 }
734
735 if (*pch == L'"')
736 *(pch - 1) = UNICODE_NULL;
737 }
738
739 return psz;
740}
uint16_t * PWCHAR
Definition: typedefs.h:56

◆ SHFindComputer()

EXTERN_C BOOL WINAPI SHFindComputer ( LPCITEMIDLIST  pidlRoot,
LPCITEMIDLIST  pidlSavedSearch 
)

Definition at line 750 of file utils.cpp.

751{
752 UNREFERENCED_PARAMETER(pidlRoot);
753 UNREFERENCED_PARAMETER(pidlSavedSearch);
754
755 TRACE("%p %p\n", pidlRoot, pidlSavedSearch);
756
757 IContextMenu *pCM;
758 HRESULT hr = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
759 IID_IContextMenu, (void **)&pCM);
760 if (FAILED(hr))
761 {
762 ERR("0x%08X\n", hr);
763 return hr;
764 }
765
766 CMINVOKECOMMANDINFO InvokeInfo = { sizeof(InvokeInfo) };
767 InvokeInfo.lpParameters = "{996E1EB1-B524-11D1-9120-00A0C98BA67D}";
768 InvokeInfo.nShow = SW_SHOWNORMAL;
769 hr = pCM->InvokeCommand(&InvokeInfo);
770 pCM->Release();
771
772 return SUCCEEDED(hr);
773}
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT InvokeCommand([in] LPCMINVOKECOMMANDINFO lpici)
#define SW_SHOWNORMAL
Definition: winuser.h:770

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

◆ SHGetAttributes()

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

Definition at line 246 of file utils.cpp.

247{
248 LPCITEMIDLIST pidlLast = pidl;
249 IShellFolder *release = NULL;
250
251 if (!psf)
252 {
253 SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
254 if (!psf)
255 return 0;
256 release = psf;
257 }
258
259 DWORD oldAttrs = dwAttributes;
260 if (FAILED(psf->GetAttributesOf(1, &pidlLast, &dwAttributes)))
261 dwAttributes = 0;
262 else
263 dwAttributes &= oldAttrs;
264
265 if ((dwAttributes & SFGAO_FOLDER) &&
266 (dwAttributes & SFGAO_STREAM) &&
267 !(dwAttributes & SFGAO_STORAGEANCESTOR) &&
268 (oldAttrs & SFGAO_STORAGEANCESTOR) &&
269 (SHGetObjectCompatFlags(psf, NULL) & 0x200))
270 {
271 dwAttributes &= ~(SFGAO_STREAM | SFGAO_STORAGEANCESTOR);
272 dwAttributes |= SFGAO_STORAGEANCESTOR;
273 }
274
275 if (release)
276 release->Release();
277 return dwAttributes;
278}
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:6278
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1350
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
DWORD dwAttributes
Definition: vdmdbg.h:34

Referenced by CFSDropTarget::_DoDrop(), CGuidItemContextMenu_CreateInstance(), and SHGetNameAndFlagsW().

◆ SHGetNameAndFlagsW()

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

Definition at line 289 of file utils.cpp.

295{
296 if (pszText)
297 *pszText = UNICODE_NULL;
298
300
301 CComPtr<IShellFolder> psfFolder;
302 LPCITEMIDLIST ppidlLast;
303 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfFolder), &ppidlLast);
304 if (SUCCEEDED(hr))
305 {
306 if (pszText)
307 hr = Shell_DisplayNameOf(psfFolder, ppidlLast, dwFlags, pszText, cchBuf);
308
309 if (SUCCEEDED(hr))
310 {
311 if (pdwAttributes)
312 *pdwAttributes = SHGetAttributes(psfFolder, ppidlLast, *pdwAttributes);
313 }
314 }
315
316 if (SUCCEEDED(hrCoInit))
318
319 return hr;
320}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT Shell_DisplayNameOf(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
Definition: utils.cpp:230
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:246
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:280

Referenced by DoGetFileTitle(), 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 1260 of file utils.cpp.

1264{
1265 HRESULT hr;
1266 STRRET strret;
1268 SFGAOF attrs;
1269
1270 *ppidlReal = NULL;
1271
1272 hr = IShellFolder_GetDisplayNameOf(psf, pidlSimple, SHGDN_INFOLDER | SHGDN_FORPARSING,
1273 &strret, 0);
1275 return hr;
1276
1277 hr = StrRetToBufW(&strret, pidlSimple, szPath, _countof(szPath));
1279 return hr;
1280
1281 attrs = SFGAO_FILESYSTEM;
1282 hr = psf->GetAttributesOf(1, &pidlSimple, &attrs);
1283 if (SUCCEEDED(hr) && !(attrs & SFGAO_FILESYSTEM))
1284 return SHILClone(pidlSimple, ppidlReal);
1285
1286 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, szPath, NULL, ppidlReal, NULL);
1287 if (hr == E_INVALIDARG || hr == E_NOTIMPL)
1288 return SHILClone(pidlSimple, ppidlReal);
1289
1290 return hr;
1291}
#define E_NOTIMPL
Definition: ddrawi.h:99
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:13
#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 647 of file utils.cpp.

648{
651 HRESULT hr;
652 CStringW strShellStyle;
653
654 TRACE("SHGetShellStyleHInstance called\n");
655
656 /* First, attempt to load the shellstyle dll from the current active theme */
658 if (FAILED(hr))
659 goto DoDefault;
660
661 /* Strip the theme filename */
663
664 strShellStyle = szPath;
665 strShellStyle += L"\\Shell\\";
666 strShellStyle += szColorName;
667 strShellStyle += L"\\ShellStyle.dll";
668
670 if (hInst)
671 return hInst;
672
673 /* Otherwise, use the version stored in the System32 directory */
674DoDefault:
675 if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
677 {
678 ERR("Expand failed\n");
679 return NULL;
680 }
682}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:894
static const WCHAR szColorName[]
Definition: system.c:40
HINSTANCE hInst
Definition: dxdiag.c:13
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342

◆ SHGetUserSessionId()

EXTERN_C DWORD WINAPI SHGetUserSessionId ( _In_opt_ HANDLE  hToken)

Definition at line 502 of file utils.cpp.

503{
504 DWORD dwSessionId, dwLength;
505 BOOL bOpenToken = FALSE;
506
507 TRACE("%p\n", hToken);
508
509 if (!hToken)
510 bOpenToken = SHOpenEffectiveToken(&hToken);
511
512 if (!hToken ||
513 !GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
514 {
515 dwSessionId = 0;
516 }
517
518 if (bOpenToken)
519 CloseHandle(hToken);
520
521 return dwSessionId;
522}
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:493
@ TokenSessionId
Definition: setypes.h:977

◆ SHILAppend()

HRESULT SHILAppend ( _Inout_ LPITEMIDLIST  pidl,
_Inout_ LPITEMIDLIST ppidl 
)

Definition at line 73 of file utils.cpp.

74{
75 LPITEMIDLIST pidlOld = *ppidl;
76 if (!pidlOld)
77 {
78 *ppidl = pidl;
79 return S_OK;
80 }
81
82 HRESULT hr = SHILCombine(*ppidl, pidl, ppidl);
83 ILFree(pidlOld);
84 ILFree(pidl);
85 return hr;
86}
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:940

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

◆ SHILClone()

HRESULT SHILClone ( _In_opt_ LPCITEMIDLIST  pidl,
_Outptr_ LPITEMIDLIST ppidl 
)

Definition at line 13 of file utils.cpp.

16{
17 if (!pidl)
18 {
19 *ppidl = NULL;
20 return S_OK;
21 }
22 *ppidl = ILClone(pidl);
23 return (*ppidl ? S_OK : E_OUTOFMEMORY);
24}
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237

Referenced by BrFolder_Treeview_Rename(), CShellBrowser::GetPidl(), CCopyMoveToMenu::Initialize(), CShellBrowser::OpenNewBrowserWindow(), CFSFolder::SetNameOf(), CRegFolder::SetNameOf(), SHGetRealIDL(), and CExplorerBand::UpdateBrowser().

◆ SHInvokePrivilegedFunctionW()

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

Definition at line 529 of file utils.cpp.

533{
534 TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
535
536 if (!pszName || !fn)
537 return E_INVALIDARG;
538
539 HANDLE hToken = NULL;
540 TOKEN_PRIVILEGES NewPriv, PrevPriv;
541 BOOL bAdjusted = FALSE;
542
543 if (SHOpenEffectiveToken(&hToken) &&
544 ::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
545 {
546 NewPriv.PrivilegeCount = 1;
548
549 DWORD dwReturnSize;
550 bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
551 sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
552 }
553
554 HRESULT hr = fn(lParam);
555
556 if (bAdjusted)
557 ::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
558
559 if (hToken)
560 ::CloseHandle(hToken);
561
562 return hr;
563}
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:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

◆ SHIsFileSysBindCtx()

HRESULT SHIsFileSysBindCtx ( _In_ IBindCtx pBindCtx,
_Out_opt_ WIN32_FIND_DATAW pFindData 
)

Definition at line 153 of file utils.cpp.

154{
157
158 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam((LPWSTR)STR_FILE_SYS_BIND_DATA, &punk)))
159 return S_FALSE;
160
161 if (FAILED(punk->QueryInterface(IID_PPV_ARG(IFileSystemBindData, &pBindData))))
162 return S_FALSE;
163
164 if (pFindData)
165 pBindData->GetFindData(pFindData);
166
167 return S_OK;
168}
#define S_FALSE
Definition: winerror.h:2357

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

◆ SHOpenEffectiveToken()

EXTERN_C BOOL WINAPI SHOpenEffectiveToken ( _Out_ LPHANDLE  phToken)

Definition at line 493 of file utils.cpp.

494{
495 TRACE("%p\n", phToken);
497}
static BOOL OpenEffectiveToken(_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
Definition: utils.cpp:89
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928

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

◆ SHOpenPropSheetA()

EXTERN_C BOOL WINAPI SHOpenPropSheetA ( _In_opt_ LPCSTR  pszCaption,
_In_opt_ HKEY ahKeys,
_In_ UINT  cKeys,
_In_ const CLSID pclsidDefault,
_In_ IDataObject pDataObject,
_In_opt_ IShellBrowser pShellBrowser,
_In_opt_ LPCSTR  pszStartPage 
)

Definition at line 1055 of file utils.cpp.

1063{
1064 CStringW strStartPageW, strCaptionW;
1065 LPCWSTR pszCaptionW = NULL, pszStartPageW = NULL;
1066
1067 TRACE("(%s, %p, %u, %p, %p, %p, %s)", debugstr_a(pszCaption), ahKeys, cKeys, pclsidDefault,
1068 pDataObject, pShellBrowser, debugstr_a(pszStartPage));
1069
1070 if (pszCaption)
1071 {
1072 strStartPageW = pszCaption;
1073 pszCaptionW = strCaptionW;
1074 }
1075
1076 if (pszStartPage)
1077 {
1078 strStartPageW = pszStartPage;
1079 pszStartPageW = strStartPageW;
1080 }
1081
1082 return SHOpenPropSheetW(pszCaptionW, ahKeys, cKeys, pclsidDefault,
1083 pDataObject, pShellBrowser, pszStartPageW);
1084}
BOOL WINAPI SHOpenPropSheetW(_In_opt_ LPCWSTR pszCaption, _In_opt_ HKEY *ahKeys, _In_ UINT cKeys, _In_ const CLSID *pclsidDefault, _In_ IDataObject *pDataObject, _In_opt_ IShellBrowser *pShellBrowser, _In_opt_ LPCWSTR pszStartPage)
Definition: stubs.cpp:219

◆ ShortSizeFormatW()

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

Definition at line 482 of file utils.cpp.

485{
486 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
487 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
488}
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388

◆ SHSetFolderPathA()

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

Definition at line 429 of file utils.cpp.

434{
435 TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
436 CStringW strPathW(pszPath);
437 return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
438}
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:886

◆ SHSkipJunctionBinding()

BOOL SHSkipJunctionBinding ( _In_ IBindCtx pbc,
_In_ CLSID pclsid 
)

Definition at line 141 of file utils.cpp.

142{
143 if (!pbc)
144 return FALSE;
145
146 BIND_OPTS BindOps = { sizeof(BindOps) };
147 if (SUCCEEDED(pbc->GetBindOptions(&BindOps)) && BindOps.grfFlags == OLECONTF_LINKS)
148 return TRUE;
149
150 return pclsid && SHSkipJunction(pbc, pclsid);
151}
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4558

Referenced by CDesktopFolder::_ParseDisplayNameByParent().

◆ SHStartNetConnectionDialogA()

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

Definition at line 1120 of file utils.cpp.

1124{
1125 LPCWSTR pszRemoteNameW = NULL;
1126 CStringW strRemoteNameW;
1127
1128 TRACE("(%p, %s, %lu)\n", hwnd, debugstr_a(pszRemoteName), dwType);
1129
1130 if (pszRemoteName)
1131 {
1132 strRemoteNameW = pszRemoteName;
1133 pszRemoteNameW = strRemoteNameW;
1134 }
1135
1136 return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType);
1137}
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:618

Referenced by SHStartNetConnectionDialog().

◆ SHTestTokenPrivilegeW()

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

Definition at line 572 of file utils.cpp.

575{
576 LUID Luid;
578 PTOKEN_PRIVILEGES pTokenPriv;
579 HANDLE hNewToken = NULL;
580 BOOL ret = FALSE;
581
582 TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
583
584 if (!lpName)
585 return FALSE;
586
587 if (!hToken)
588 {
589 if (!SHOpenEffectiveToken(&hNewToken))
590 goto Quit;
591
592 if (!hNewToken)
593 return FALSE;
594
595 hToken = hNewToken;
596 }
597
598 if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
599 return FALSE;
600
601 dwLength = 0;
603 goto Quit;
604
606 if (!pTokenPriv)
607 goto Quit;
608
609 if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
610 {
611 UINT iPriv, cPrivs;
612 cPrivs = pTokenPriv->PrivilegeCount;
613 for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
614 {
615 ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
616 }
617 }
618
619 LocalFree(pTokenPriv);
620
621Quit:
622 if (hToken == hNewToken)
623 CloseHandle(hNewToken);
624
625 return ret;
626}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define LPTR
Definition: winbase.h:381
_In_ LPCSTR lpName
Definition: winbase.h:2789
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
@ TokenPrivileges
Definition: setypes.h:968
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES

Referenced by IsShutdownAllowed().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )