ReactOS 0.4.17-dev-304-g69474b3
utils.cpp File Reference
#include "precomp.h"
#include <winver.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <shlobj_undoc.h>
#include <shlguid_undoc.h>
#include <userenv.h>
#include <atlstr.h>
#include <shlwapi_undoc.h>
#include <ishellfolder_helpers.h>
#include <strsafe.h>
Include dependency graph for utils.cpp:

Go to the source code of this file.

Classes

struct  RETRY_DATA
 
struct  tagSHDIALOG
 

Macros

#define _ATL_NO_EXCEPTIONS
 
#define IShellFolder_GetDisplayNameOf   _disabled_IShellFolder_GetDisplayNameOf_
 
#define IShellFolder_ParseDisplayName   _disabled_IShellFolder_ParseDisplayName_
 
#define IShellFolder_CompareIDs   _disabled_IShellFolder_CompareIDs_
 
#define FAILED_UNEXPECTEDLY   FAILED /* FIXME: Make shellutils.h usable without ATL */
 

Typedefs

typedef struct tagSHDIALOG SHDIALOG
 
typedef struct tagSHDIALOGPSHDIALOG
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C LSTATUS WINAPI RegGetValueW (HKEY, LPCWSTR, LPCWSTR, DWORD, LPDWORD, PVOID, LPDWORD)
 
static WORD GetVersionMajorMinor ()
 
static BOOL UnExpandEnvironmentStringForUserA (_In_ HANDLE hUserToken, _In_ PCSTR lpString, _In_ PCSTR lpSrc, _Out_ PSTR pszDest, _In_ INT cchDest)
 
static BOOL UnExpandEnvironmentStringForUserW (_In_ HANDLE hUserToken, _In_ PCWSTR lpString, _In_ PCWSTR lpSrc, _Out_ PWSTR pszDest, _In_ INT cchDest)
 
EXTERN_C BOOL WINAPI PathUnExpandEnvStringsForUserA (_In_ HANDLE hUserToken, _In_ PCSTR pszPath, _Out_writes_(cchBuff) PSTR pszBuff, _In_ INT cchBuff)
 
EXTERN_C BOOL WINAPI PathUnExpandEnvStringsForUserW (_In_ HANDLE hUserToken, _In_ PCWSTR pwszPath, _Out_writes_(cchBuff) PWSTR pszBuff, _In_ INT cchBuff)
 
EXTERN_C HRESULT WINAPI MapWin32ErrorToSTG (_In_ HRESULT hr)
 
static BOOL CharLowerNoDBCSAWorker (PSTR lpString, INT cchMax, BOOL bUppercase)
 
static BOOL CharLowerNoDBCSWWorker (PWSTR lpString, INT cchMax, BOOL bUppercase)
 
EXTERN_C PSTR WINAPI CharLowerNoDBCSA (_Inout_ PSTR lpString)
 
EXTERN_C PWSTR WINAPI CharLowerNoDBCSW (_Inout_ PWSTR lpString)
 
EXTERN_C PSTR WINAPI CharUpperNoDBCSA (_Inout_ PSTR lpString)
 
EXTERN_C PWSTR WINAPI CharUpperNoDBCSW (_Inout_ PWSTR lpString)
 
static HRESULT SHInvokeCommandOnContextMenuInternal (_In_opt_ HWND hWnd, _In_opt_ IUnknown *pUnk, _In_ IContextMenu *pCM, _In_ UINT fCMIC, _In_ UINT fCMF, _In_opt_ LPCSTR pszVerb, _In_opt_ LPCWSTR pwszDir, _In_ bool ForceQCM)
 
EXTERN_C HRESULT WINAPI SHInvokeCommandOnContextMenuEx (_In_opt_ HWND hWnd, _In_opt_ IUnknown *pUnk, _In_ IContextMenu *pCM, _In_ UINT fCMIC, _In_ UINT fCMF, _In_opt_ LPCSTR pszVerb, _In_opt_ LPCWSTR pwszDir)
 
EXTERN_C HRESULT WINAPI SHInvokeCommandOnContextMenu (_In_opt_ HWND hWnd, _In_opt_ IUnknown *pUnk, _In_ IContextMenu *pCM, _In_ UINT fCMIC, _In_opt_ LPCSTR pszVerb)
 
static BOOL IsTextAsciiOnly (PCSTR psz)
 
EXTERN_C HRESULT WINAPI SHInvokeCommandsOnContextMenu (_In_opt_ HWND hwnd, _In_opt_ IUnknown *punkSite, _In_ IContextMenu *pCM, _In_ DWORD fMask, _In_reads_opt_(cVerbs) PCSTR *pVerbs, _In_ UINT cVerbs)
 
EXTERN_C HRESULT WINAPI SHInvokeCommandWithFlagsAndSite (_In_opt_ HWND hWnd, _In_opt_ IUnknown *pUnk, _In_ IShellFolder *pShellFolder, _In_ LPCITEMIDLIST pidl, _In_ UINT fCMIC, _In_opt_ LPCSTR pszVerb)
 
EXTERN_C BOOL WINAPI IContextMenu_Invoke (_In_ IContextMenu *pContextMenu, _In_ HWND hwnd, _In_ LPCSTR lpVerb, _In_ UINT uFlags)
 
static HRESULT ShellExecuteCommand (_In_opt_ HWND hWnd, _In_ PCWSTR Command, _In_opt_ UINT Flags)
 
EXTERN_C HRESULT WINAPI RunRegCommand (_In_opt_ HWND hWnd, _In_ HKEY hKey, _In_opt_ PCWSTR pszSubKey)
 
EXTERN_C HRESULT WINAPI RunIndirectRegCommand (_In_opt_ HWND hWnd, _In_ HKEY hKey, _In_opt_ PCWSTR pszSubKey, _In_ PCWSTR pszVerb)
 
EXTERN_C HRESULT WINAPI SHRunIndirectRegClientCommand (_In_opt_ HWND hWnd, _In_ PCWSTR pszClientType)
 
BOOL WINAPI PathFileExistsDefExtAndAttributesW (_Inout_ LPWSTR pszPath, _In_ DWORD dwWhich, _Out_opt_ LPDWORD pdwFileAttributes)
 
static BOOL SHLWAPI_IsBogusHRESULT (HRESULT hr)
 
EXTERN_C HRESULT WINAPI IShellFolder_GetDisplayNameOf (_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ SHGDNF uFlags, _Out_ LPSTRRET lpName, _In_ DWORD dwRetryFlags)
 
EXTERN_C HRESULT WINAPI IShellFolder_ParseDisplayName (_In_ IShellFolder *psf, _In_opt_ HWND hwndOwner, _In_opt_ LPBC pbcReserved, _In_ LPOLESTR lpszDisplayName, _Out_opt_ ULONG *pchEaten, _Out_opt_ PIDLIST_RELATIVE *ppidl, _Out_opt_ ULONG *pdwAttributes)
 
EXTERN_C HRESULT WINAPI IShellFolder_CompareIDs (_In_ IShellFolder *psf, _In_ LPARAM lParam, _In_ PCUIDLIST_RELATIVE pidl1, _In_ PCUIDLIST_RELATIVE pidl2)
 
static INT_PTR CALLBACK SHDialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
EXTERN_C INT_PTR WINAPI SHDialogBox (_In_opt_ HINSTANCE hInstance, _In_ PCSTR lpTemplateName, _In_opt_ HWND hWndParent, _In_opt_ SHDIALOGPROC fn, _In_opt_ PVOID pThis)
 
EXTERN_C PSTR WINAPI NextPathA (_In_ PCSTR pszStart, _Out_writes_(cchDest) PSTR pszDest, _In_ UINT cchDest)
 
EXTERN_C PWSTR WINAPI NextPathW (_In_ PCWSTR pszStart, _Out_writes_(cchDest) PWSTR pszDest, _In_ UINT cchDest)
 
static HRESULT _AllocValueString (HKEY hkey, PCWSTR pszSubKey, PCWSTR pszValue, PWSTR *ppszOut)
 
EXTERN_C HRESULT WINAPI IUnknown_ShowBrowserBar (_In_ IUnknown *punk, _In_ REFGUID rguid, _In_ BOOL bShow)
 
VOID WINAPI PrettifyFileDescriptionW (_Inout_ PWSTR pszTarget, _In_opt_ PCWSTR pszCutList)
 
BOOL WINAPI SHGetFileDescriptionW (_In_ PCWSTR pszPath, _In_opt_ PCWSTR pszVerKey, _In_opt_ PCWSTR pszDisplayName, _Out_opt_ PWSTR pszOut, _Inout_ PUINT pcchOut)
 
BOOL WINAPI SHGetFileDescriptionA (_In_ PCSTR pszPath, _In_opt_ PCSTR pszVerKey, _In_opt_ PCSTR pszDisplayName, _Out_opt_ PSTR pszOut, _Inout_ PUINT pcchOut)
 

Variables

static const RETRY_DATA g_RetryData []
 

Macro Definition Documentation

◆ _ATL_NO_EXCEPTIONS

#define _ATL_NO_EXCEPTIONS

Definition at line 8 of file utils.cpp.

◆ FAILED_UNEXPECTEDLY

#define FAILED_UNEXPECTEDLY   FAILED /* FIXME: Make shellutils.h usable without ATL */

Definition at line 32 of file utils.cpp.

◆ IShellFolder_CompareIDs

#define IShellFolder_CompareIDs   _disabled_IShellFolder_CompareIDs_

Definition at line 15 of file utils.cpp.

◆ IShellFolder_GetDisplayNameOf

#define IShellFolder_GetDisplayNameOf   _disabled_IShellFolder_GetDisplayNameOf_

Definition at line 13 of file utils.cpp.

◆ IShellFolder_ParseDisplayName

#define IShellFolder_ParseDisplayName   _disabled_IShellFolder_ParseDisplayName_

Definition at line 14 of file utils.cpp.

Typedef Documentation

◆ PSHDIALOG

◆ SHDIALOG

Function Documentation

◆ _AllocValueString()

static HRESULT _AllocValueString ( HKEY  hkey,
PCWSTR  pszSubKey,
PCWSTR  pszValue,
PWSTR ppszOut 
)
static

Definition at line 986 of file utils.cpp.

991{
992 *ppszOut = NULL;
993
996 if (error)
998
999 PWSTR pszData = (PWSTR)LocalAlloc(LPTR, cbData);
1000 if (!pszData)
1002
1003 error = SHGetValueW(hkey, pszSubKey, pszValue, NULL, pszData, &cbData);
1004 if (error)
1005 {
1006 LocalFree(pszData);
1007 return HRESULT_FROM_WIN32(error);
1008 }
1009
1010 *ppszOut = pszData;
1011 return S_OK;
1012}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1278
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define S_OK
Definition: intsafe.h:52
#define LPTR
Definition: minwinbase.h:93
#define error(str)
Definition: mkdosfs.c:1605
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
_In_opt_ LPCSTR pszSubKey
Definition: shlwapi.h:783
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783
uint16_t * PWSTR
Definition: typedefs.h:56
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by PrettifyFileDescriptionW().

◆ CharLowerNoDBCSA()

EXTERN_C PSTR WINAPI CharLowerNoDBCSA ( _Inout_ PSTR  lpString)

Definition at line 274 of file utils.cpp.

275{
276 return CharLowerNoDBCSAWorker(lpString, 0, FALSE) ? lpString : NULL;
277}
#define FALSE
Definition: types.h:117
static BOOL CharLowerNoDBCSAWorker(PSTR lpString, INT cchMax, BOOL bUppercase)
Definition: utils.cpp:245

◆ CharLowerNoDBCSAWorker()

static BOOL CharLowerNoDBCSAWorker ( PSTR  lpString,
INT  cchMax,
BOOL  bUppercase 
)
static

Definition at line 245 of file utils.cpp.

246{
247 CHAR szBuff[MAX_PATH];
248 INT cch;
249 if (!lpString)
250 return FALSE;
251 cch = cchMax ? cchMax : lstrlenA(lpString);
252 if (FAILED(StringCchCopyA(szBuff, _countof(szBuff), lpString)))
253 return FALSE;
255 szBuff, cch, lpString, cch);
256}
UINT cchMax
#define MAX_PATH
Definition: compat.h:34
INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen, LPSTR dst, INT dstlen)
Definition: locale.c:3834
#define FAILED(hr)
Definition: intsafe.h:51
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define LOCALE_SYSTEM_DEFAULT
char CHAR
Definition: pedump.c:57
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
int32_t INT
Definition: typedefs.h:58
#define LCMAP_UPPERCASE
Definition: winnls.h:202
#define LCMAP_LOWERCASE
Definition: winnls.h:201

Referenced by CharLowerNoDBCSA(), and CharUpperNoDBCSA().

◆ CharLowerNoDBCSW()

EXTERN_C PWSTR WINAPI CharLowerNoDBCSW ( _Inout_ PWSTR  lpString)

Definition at line 282 of file utils.cpp.

283{
284 return CharLowerNoDBCSWWorker(lpString, 0, FALSE) ? lpString : NULL;
285}
static BOOL CharLowerNoDBCSWWorker(PWSTR lpString, INT cchMax, BOOL bUppercase)
Definition: utils.cpp:258

◆ CharLowerNoDBCSWWorker()

static BOOL CharLowerNoDBCSWWorker ( PWSTR  lpString,
INT  cchMax,
BOOL  bUppercase 
)
static

Definition at line 258 of file utils.cpp.

259{
260 WCHAR szDest[MAX_PATH];
261 INT cch;
262 if (!lpString)
263 return FALSE;
264 cch = cchMax ? cchMax : lstrlenW(lpString);
265 if (FAILED(StringCchCopyW(szDest, _countof(szDest), lpString)))
266 return FALSE;
268 szDest, cch, lpString, cch);
269}
#define lstrlenW
Definition: compat.h:750
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3808
short WCHAR
Definition: pedump.c:58
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by CharLowerNoDBCSW(), and CharUpperNoDBCSW().

◆ CharUpperNoDBCSA()

EXTERN_C PSTR WINAPI CharUpperNoDBCSA ( _Inout_ PSTR  lpString)

Definition at line 290 of file utils.cpp.

291{
292 return CharLowerNoDBCSAWorker(lpString, 0, TRUE) ? lpString : NULL;
293}
#define TRUE
Definition: types.h:120

◆ CharUpperNoDBCSW()

EXTERN_C PWSTR WINAPI CharUpperNoDBCSW ( _Inout_ PWSTR  lpString)

Definition at line 298 of file utils.cpp.

299{
300 return CharLowerNoDBCSWWorker(lpString, 0, TRUE) ? lpString : NULL;
301}

◆ GetVersionMajorMinor()

static WORD GetVersionMajorMinor ( )
inlinestatic

Definition at line 40 of file utils.cpp.

41{
44}
static const WCHAR version[]
Definition: asmname.c:66
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define MAKEWORD(a, b)
Definition: typedefs.h:248

Referenced by SHInvokeCommandOnContextMenuInternal().

◆ IContextMenu_Invoke()

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

Definition at line 556 of file utils.cpp.

561{
562 TRACE("(%p, %p, %s, %u)\n", pContextMenu, hwnd, debugstr_a(lpVerb), uFlags);
564 uFlags, lpVerb, NULL, false);
565 return !FAILED_UNEXPECTEDLY(hr);
566}
HRESULT hr
Definition: delayimp.cpp:582
UINT uFlags
Definition: api.c:59
static HRESULT SHInvokeCommandOnContextMenuInternal(_In_opt_ HWND hWnd, _In_opt_ IUnknown *pUnk, _In_ IContextMenu *pCM, _In_ UINT fCMIC, _In_ UINT fCMF, _In_opt_ LPCSTR pszVerb, _In_opt_ LPCWSTR pwszDir, _In_ bool ForceQCM)
Definition: utils.cpp:304
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:32
#define debugstr_a
Definition: kernel32.h:31
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ IShellFolder_CompareIDs()

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

Definition at line 807 of file utils.cpp.

812{
813 TRACE("(%p, %p, %p, %p)\n", psf, lParam, pidl1, pidl2);
814
815 if (lParam & ~(SIZE_T)SHCIDS_COLUMNMASK)
816 {
817 /* Try as IShellFolder2 if possible */
818 HRESULT hr = psf->QueryInterface(IID_IShellFolder2, (void **)&psf);
819 if (FAILED(hr))
820 lParam &= SHCIDS_COLUMNMASK;
821 else
822 psf->Release();
823 }
824
825 return psf->CompareIDs(lParam, pidl1, pidl2);
826}
LPARAM lParam
Definition: combotst.c:139
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
nsrefcnt Release()
ULONG_PTR SIZE_T
Definition: typedefs.h:80

◆ IShellFolder_GetDisplayNameOf()

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

Definition at line 719 of file utils.cpp.

725{
726 HRESULT hr;
727
728 TRACE("(%p)->(%p, 0x%lX, %p, 0x%lX)\n", psf, pidl, uFlags, lpName, dwRetryFlags);
729
730 hr = psf->GetDisplayNameOf(pidl, uFlags, lpName);
732 return hr;
733
734 dwRetryFlags |= SFGDNO_RETRYALWAYS;
735
736 if ((uFlags & SHGDN_FORPARSING) == 0)
737 dwRetryFlags |= SFGDNO_RETRYWITHFORPARSING;
738
739 // Retry with other flags to get successful results
740 for (SIZE_T iEntry = 0; iEntry < _countof(g_RetryData); ++iEntry)
741 {
742 const RETRY_DATA *pData = &g_RetryData[iEntry];
743 if (!(dwRetryFlags & pData->dwRetryFlags))
744 continue;
745
746 SHGDNF uNewFlags = ((uFlags & ~pData->uRemove) | pData->uAdd);
747 if (uNewFlags == uFlags)
748 continue;
749
750 hr = psf->GetDisplayNameOf(pidl, uNewFlags, lpName);
752 break;
753
754 uFlags = uNewFlags; // Update flags every time
755 }
756
757 return hr;
758}
static const RETRY_DATA g_RetryData[]
Definition: utils.cpp:702
static BOOL SHLWAPI_IsBogusHRESULT(HRESULT hr)
Definition: utils.cpp:690
#define SFGDNO_RETRYWITHFORPARSING
#define SFGDNO_RETRYALWAYS
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_In_ LPCSTR lpName
Definition: winbase.h:2519

◆ IShellFolder_ParseDisplayName()

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

Definition at line 767 of file utils.cpp.

775{
776 ULONG dummy1, dummy2;
777
778 TRACE("(%p)->(%p, %p, %s, %p, %p, %p)\n", psf, hwndOwner, pbcReserved,
779 debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
780
781 if (!pdwAttributes)
782 {
783 dummy1 = 0;
784 pdwAttributes = &dummy1;
785 }
786
787 if (!pchEaten)
788 {
789 dummy2 = 0;
790 pchEaten = &dummy2;
791 }
792
793 if (ppidl)
794 *ppidl = NULL;
795
796 return psf->ParseDisplayName(hwndOwner, pbcReserved, lpszDisplayName, pchEaten,
797 ppidl, pdwAttributes);
798}
#define debugstr_w
Definition: kernel32.h:32
uint32_t ULONG
Definition: typedefs.h:59

◆ IsTextAsciiOnly()

static BOOL IsTextAsciiOnly ( PCSTR  psz)
inlinestatic

Definition at line 420 of file utils.cpp.

421{
422 for (const signed char *pch = (const signed char *)psz; *pch; ++pch)
423 {
424 if (*pch < 0)
425 return FALSE;
426 }
427 return TRUE;
428}
#define pch(ap)
Definition: match.c:418

Referenced by SHInvokeCommandsOnContextMenu().

◆ IUnknown_ShowBrowserBar()

EXTERN_C HRESULT WINAPI IUnknown_ShowBrowserBar ( _In_ IUnknown punk,
_In_ REFGUID  rguid,
_In_ BOOL  bShow 
)

Definition at line 1020 of file utils.cpp.

1024{
1026 HRESULT hr = IUnknown_QueryServiceForWebBrowserApp(punk, IID_IWebBrowser2, (PVOID*)&pWB2);
1027 if (FAILED(hr))
1028 return hr;
1029
1030 WCHAR szGUID[40];
1031 StringFromGUID2(rguid, szGUID, _countof(szGUID));
1032
1033 CComVariant varClsid(szGUID), varShow((bool)!!bShow), varSize;
1034 return pWB2->ShowBrowserBar(&varClsid, &varShow, &varSize);
1035}
INT WINAPI StringFromGUID2(REFGUID guid, LPOLESTR str, INT cmax)
Definition: combase.c:1525
HRESULT WINAPI IUnknown_QueryServiceForWebBrowserApp(IUnknown *lpUnknown, REFGUID riid, LPVOID *lppOut)
Definition: ordinal.c:5615
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158

◆ MapWin32ErrorToSTG()

EXTERN_C HRESULT WINAPI MapWin32ErrorToSTG ( _In_ HRESULT  hr)

Definition at line 228 of file utils.cpp.

229{
230 switch (hr)
231 {
240 default:
241 return hr;
242 }
243}
return
Definition: dirsup.c:529
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define STG_E_FILEALREADYEXISTS
Definition: winerror.h:3674
#define STG_E_FILENOTFOUND
Definition: winerror.h:3660
#define ERROR_FILE_EXISTS
Definition: winerror.h:287
#define STG_E_ACCESSDENIED
Definition: winerror.h:3663

◆ NextPathA()

EXTERN_C PSTR WINAPI NextPathA ( _In_ PCSTR  pszStart,
_Out_writes_(cchDest) PSTR  pszDest,
_In_ UINT  cchDest 
)

Definition at line 912 of file utils.cpp.

916{
917 if (!pszStart)
918 return NULL;
919
920 PCSTR pchStart = pszStart;
921 while (*pchStart == ';')
922 ++pchStart;
923
924 if (!*pchStart)
925 return NULL;
926
927 PSTR pchEnd = StrChrA(pchStart, ';');
928 if (!pchEnd)
929 pchEnd = (PSTR)(pchStart + lstrlenA(pchStart));
930
931 const UINT cchSegment = (UINT)(pchEnd - pchStart);
932 const UINT cchToCopy = min(cchSegment + 1, cchDest);
933 lstrcpynA(pszDest, pchStart, cchToCopy);
934 pszDest[cchSegment] = ANSI_NULL;
935
936 PathRemoveBlanksA(pszDest);
937 if (!*pszDest)
938 return NULL;
939
940 return (*pchEnd == ';') ? (pchEnd + 1) : pchEnd;
941}
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
Definition: string.c:266
#define lstrcpynA
Definition: compat.h:751
void WINAPI PathRemoveBlanksA(char *path)
Definition: path.c:1862
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define ANSI_NULL
_In_ INT cchDest
Definition: shlwapi.h:1151
char * PSTR
Definition: typedefs.h:51
const char * PCSTR
Definition: typedefs.h:52

◆ NextPathW()

EXTERN_C PWSTR WINAPI NextPathW ( _In_ PCWSTR  pszStart,
_Out_writes_(cchDest) PWSTR  pszDest,
_In_ UINT  cchDest 
)

Definition at line 954 of file utils.cpp.

958{
959 if (!pszStart)
960 return NULL;
961
962 PCWSTR pchStart = pszStart;
963 while (*pchStart == L';')
964 ++pchStart;
965
966 if (!*pchStart)
967 return NULL;
968
969 PWSTR pchEnd = StrChrW(pchStart, L';');
970 if (!pchEnd)
971 pchEnd = (PWSTR)(pchStart + lstrlenW(pchStart));
972
973 const UINT cchSegment = (UINT)(pchEnd - pchStart);
974 const UINT cchToCopy = min(cchSegment + 1, cchDest);
975 lstrcpynW(pszDest, pchStart, cchToCopy);
976 pszDest[cchSegment] = UNICODE_NULL;
977
978 PathRemoveBlanksW(pszDest);
979 if (!*pszDest)
980 return NULL;
981
982 return (*pchEnd == L';') ? (pchEnd + 1) : pchEnd;
983}
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464
#define lstrcpynW
Definition: compat.h:738
void WINAPI PathRemoveBlanksW(WCHAR *path)
Definition: path.c:1886
#define L(x)
Definition: resources.c:13
#define UNICODE_NULL
const uint16_t * PCWSTR
Definition: typedefs.h:57

◆ PathFileExistsDefExtAndAttributesW()

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

Definition at line 660 of file utils.cpp.

664{
665 TRACE("(%s, 0x%lX, %p)\n", debugstr_w(pszPath), dwWhich, pdwFileAttributes);
666
667 if (pdwFileAttributes)
668 *pdwFileAttributes = INVALID_FILE_ATTRIBUTES;
669
670 if (!pszPath)
671 return FALSE;
672
673 if (!dwWhich || (*PathFindExtensionW(pszPath) && (dwWhich & WHICH_OPTIONAL)))
674 return PathFileExistsAndAttributesW(pszPath, pdwFileAttributes);
675
676 if (!PathFileExistsDefExtW(pszPath, dwWhich))
677 {
678 if (pdwFileAttributes)
679 *pdwFileAttributes = INVALID_FILE_ATTRIBUTES;
680 return FALSE;
681 }
682
683 if (pdwFileAttributes)
684 *pdwFileAttributes = GetFileAttributesW(pszPath);
685
686 return TRUE;
687}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1250
BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr)
Definition: path.c:1879
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1126
#define WHICH_OPTIONAL
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by START_TEST().

◆ PathUnExpandEnvStringsForUserA()

EXTERN_C BOOL WINAPI PathUnExpandEnvStringsForUserA ( _In_ HANDLE  hUserToken,
_In_ PCSTR  pszPath,
_Out_writes_(cchBuff) PSTR  pszBuff,
_In_ INT  cchBuff 
)

Definition at line 137 of file utils.cpp.

142{
143 static const PCSTR c_varsA[] =
144 {
145 "%APPDATA%",
146 "%USERPROFILE%",
147 "%ALLUSERSPROFILE%",
148 "%ProgramFiles%",
149 "%SystemRoot%",
150 "%SystemDrive%",
151 };
152
153 if (!pszPath)
154 {
155 if (pszBuff && cchBuff)
156 *pszBuff = ANSI_NULL;
157
158 return FALSE;
159 }
160
161 if (!pszBuff)
162 return FALSE;
163
164 for (size_t iVar = 0; iVar < _countof(c_varsA); ++iVar)
165 {
166 if (UnExpandEnvironmentStringForUserA(hUserToken, pszPath, c_varsA[iVar],
167 pszBuff, cchBuff))
168 {
169 return TRUE;
170 }
171 }
172
173 return FALSE;
174}
HANDLE hUserToken
Definition: install.c:39
static BOOL UnExpandEnvironmentStringForUserA(_In_ HANDLE hUserToken, _In_ PCSTR lpString, _In_ PCSTR lpSrc, _Out_ PSTR pszDest, _In_ INT cchDest)
Definition: utils.cpp:47

◆ PathUnExpandEnvStringsForUserW()

EXTERN_C BOOL WINAPI PathUnExpandEnvStringsForUserW ( _In_ HANDLE  hUserToken,
_In_ PCWSTR  pwszPath,
_Out_writes_(cchBuff) PWSTR  pszBuff,
_In_ INT  cchBuff 
)

Definition at line 183 of file utils.cpp.

188{
189 static const PCWSTR c_varsW[] =
190 {
191 L"%APPDATA%",
192 L"%USERPROFILE%",
193 L"%ALLUSERSPROFILE%",
194 L"%ProgramFiles%",
195 L"%SystemRoot%",
196 L"%SystemDrive%",
197 };
198
199 if (!pwszPath)
200 {
201 if (pszBuff && cchBuff)
202 *pszBuff = UNICODE_NULL;
203
204 return FALSE;
205 }
206
207 if (!pszBuff)
208 return FALSE;
209
210 for (size_t iVar = 0; iVar < _countof(c_varsW); ++iVar)
211 {
212 if (UnExpandEnvironmentStringForUserW(hUserToken, pwszPath, c_varsW[iVar],
213 pszBuff, cchBuff))
214 {
215 return TRUE;
216 }
217 }
218
219 return FALSE;
220}
static BOOL UnExpandEnvironmentStringForUserW(_In_ HANDLE hUserToken, _In_ PCWSTR lpString, _In_ PCWSTR lpSrc, _Out_ PWSTR pszDest, _In_ INT cchDest)
Definition: utils.cpp:89

◆ PrettifyFileDescriptionW()

VOID WINAPI PrettifyFileDescriptionW ( _Inout_ PWSTR  pszTarget,
_In_opt_ PCWSTR  pszCutList 
)

Definition at line 1043 of file utils.cpp.

1044{
1045 if (!pszTarget || !*pszTarget)
1046 return;
1047
1048 PWSTR pszFreeList = NULL;
1049 PCWSTR pszList = pszCutList;
1050 PCWSTR pszAssoc = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileAssociation";
1051 if (_AllocValueString(HKEY_LOCAL_MACHINE, pszAssoc, L"CutList", &pszFreeList) == S_OK)
1052 pszList = pszFreeList;
1053
1054 if (pszList && *pszList)
1055 {
1056 for (PCWSTR pszEntry = pszList; *pszEntry; pszEntry += lstrlenW(pszEntry) + 1)
1057 {
1058 PWSTR pszMatch = StrRStrIW(pszTarget, NULL, pszEntry);
1059 if (!pszMatch)
1060 continue;
1061
1062 if (pszMatch[lstrlenW(pszEntry)])
1063 continue;
1064
1065 *pszMatch = UNICODE_NULL;
1066 while (pszMatch > pszTarget && pszMatch[-1] == L' ')
1067 {
1068 --pszMatch;
1069 *pszMatch = UNICODE_NULL;
1070 }
1071
1072 break;
1073 }
1074 }
1075
1076 if (pszFreeList)
1077 LocalFree(pszFreeList);
1078}
LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch)
Definition: string.c:702
static HRESULT _AllocValueString(HKEY hkey, PCWSTR pszSubKey, PCWSTR pszValue, PWSTR *ppszOut)
Definition: utils.cpp:986
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by SHGetFileDescriptionW().

◆ RegGetValueW()

EXTERN_C LSTATUS WINAPI RegGetValueW ( HKEY  hKey,
LPCWSTR  pszSubKey,
LPCWSTR  pszValue,
DWORD  dwFlags,
LPDWORD  pdwType,
PVOID  pvData,
LPDWORD  pcbData 
)

Definition at line 1931 of file reg.c.

1938{
1939 DWORD dwType, cbData = pcbData ? *pcbData : 0;
1940 PVOID pvBuf = NULL;
1941 LONG ret;
1942
1943 TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
1946
1947 if (pvData && !pcbData)
1950 ((dwFlags & RRF_RT_ANY) != RRF_RT_ANY))
1952
1953 if (pszSubKey && pszSubKey[0])
1954 {
1956 if (ret != ERROR_SUCCESS) return ret;
1957 }
1958
1960
1961 /* If we are going to expand we need to read in the whole the value even
1962 * if the passed buffer was too small as the expanded string might be
1963 * smaller than the unexpanded one and could fit into cbData bytes. */
1964 if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
1965 dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))
1966 {
1967 do
1968 {
1969 HeapFree(GetProcessHeap(), 0, pvBuf);
1970
1971 pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
1972 if (!pvBuf)
1973 {
1975 break;
1976 }
1977
1978 if (ret == ERROR_MORE_DATA || !pvData)
1980 &dwType, pvBuf, &cbData);
1981 else
1982 {
1983 /* Even if cbData was large enough we have to copy the
1984 * string since ExpandEnvironmentStrings can't handle
1985 * overlapping buffers. */
1986 CopyMemory(pvBuf, pvData, cbData);
1987 }
1988
1989 /* Both the type or the value itself could have been modified in
1990 * between so we have to keep retrying until the buffer is large
1991 * enough or we no longer have to expand the value. */
1992 }
1993 while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
1994
1995 if (ret == ERROR_SUCCESS)
1996 {
1997 /* Recheck dwType in case it changed since the first call */
1998 if (dwType == REG_EXPAND_SZ)
1999 {
2001 pcbData ? *pcbData : 0) * sizeof(WCHAR);
2002 dwType = REG_SZ;
2003 if (pvData && pcbData && cbData > *pcbData)
2005 }
2006 else if (pvData)
2007 CopyMemory(pvData, pvBuf, *pcbData);
2008 }
2009
2010 HeapFree(GetProcessHeap(), 0, pvBuf);
2011 }
2012
2013 if (pszSubKey && pszSubKey[0])
2015
2017
2020
2021 if (pdwType)
2022 *pdwType = dwType;
2023
2024 if (pcbData)
2025 *pcbData = cbData;
2026
2027 return ret;
2028}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
static VOID RegpApplyRestrictions(DWORD dwFlags, DWORD dwType, DWORD cbData, PLONG ret)
Definition: reg.c:1859
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
return ret
Definition: mutex.c:146
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define ZeroMemory
Definition: minwinbase.h:31
#define CopyMemory
Definition: minwinbase.h:29
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
long LONG
Definition: pedump.c:60
_In_opt_ LPCSTR _In_opt_ LPCSTR _In_ SRRF _Out_opt_ LPDWORD pdwType
Definition: shlwapi.h:783
_In_ _Out_writes_opt_ pcchValueName _Inout_opt_ LPDWORD _Out_opt_ _Out_writes_bytes_to_opt_ pcbData _Inout_opt_ LPDWORD pcbData
Definition: shlwapi.h:757
#define RRF_NOEXPAND
Definition: winreg.h:72
#define RRF_RT_ANY
Definition: winreg.h:66
#define RRF_ZEROONFAILURE
Definition: winreg.h:73
#define RRF_RT_REG_EXPAND_SZ
Definition: winreg.h:59

Referenced by CPolicyCache::_GetValue(), AddFSClassKeysToArray(), CRegFolderEnum::AddItemsFromKey(), CDefaultContextMenu::AddStaticEntriesForKey(), AssocGetPerceivedType(), CFSExtractIcon_CreateInstance(), check_product_patches(), ComponentInfo_GetGUIDValue(), ComponentInfo_GetUINTValue(), create_monodata(), DoGetProductType(), CDefaultContextMenu::EnumerateDynamicContextHandlerForKey(), CDrvDefExt::ExtraPageProc(), FILEDLG95_MRU_get_slot(), FILEDLG95_MRU_save_filename(), FindExeCplClass(), CDrvDefExt::GeneralPageProc(), get_mono_path_registry(), get_patch_state(), get_stringvalue(), GetCLSIDForFileTypeFromExtension(), CNetConnectionPropertyUi::GetDeviceInstanceID(), GetInterfaceName(), GetRegCustomizedDriveIcon(), GetRegString(), CQueryAssociations::GetString(), HCR_GetClassNameW(), InitFunctionPtrs(), InitializeRecycleBinDlg(), InitIconOverlays(), CFileDefExt::InitOpensWithField(), COpenWithList::IsHidden(), keyboard_layout_has_altgr(), COpenWithList::Load(), load_config_driver(), load_settings(), COpenWithList::LoadFromProgIdKey(), CNewMenu::LoadItem(), LoadKeyboardLayoutW(), COpenWithList::LoadRecommendedFromHKCR(), COpenWithList::LoadRecommendedFromHKCU(), MMDevice_GetPropValue(), OpenKeyFromFileType(), PixelFormatInfo_GetChannelMask(), read_bitmap_patterns(), read_metadata_patterns(), RegQueryDword(), RunRegCommand(), COpenWithList::SetDefaultHandler(), SetupDiBuildDriverInfoList(), SHELL32_AssocGetExtensionDescription(), SHELL_GetRegCLSID(), SHELL_GetShellExtensionRegCLSID(), SHELL_QueryCLSIDValue(), SHRunIndirectRegClientCommand(), SQLGetPrivateProfileStringW(), test_keyboard_layout_name(), and WshShell3_RegRead().

◆ RunIndirectRegCommand()

EXTERN_C HRESULT WINAPI RunIndirectRegCommand ( _In_opt_ HWND  hWnd,
_In_ HKEY  hKey,
_In_opt_ PCWSTR  pszSubKey,
_In_ PCWSTR  pszVerb 
)

Definition at line 610 of file utils.cpp.

611{
612 WCHAR szKey[MAX_PATH];
613 HRESULT hr;
614 if (pszSubKey)
615 hr = StringCchPrintfW(szKey, _countof(szKey), L"%s\\shell\\%s\\command", pszSubKey, pszVerb);
616 else
617 hr = StringCchPrintfW(szKey, _countof(szKey), L"shell\\%s\\command", pszVerb);
618 return SUCCEEDED(hr) ? RunRegCommand(hWnd, hKey, szKey) : hr;
619}
HWND hWnd
Definition: settings.c:17
EXTERN_C HRESULT WINAPI RunRegCommand(_In_opt_ HWND hWnd, _In_ HKEY hKey, _In_opt_ PCWSTR pszSubKey)
Definition: utils.cpp:596
#define SUCCEEDED(hr)
Definition: intsafe.h:50
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by SHRunIndirectRegClientCommand().

◆ RunRegCommand()

EXTERN_C HRESULT WINAPI RunRegCommand ( _In_opt_ HWND  hWnd,
_In_ HKEY  hKey,
_In_opt_ PCWSTR  pszSubKey 
)

Definition at line 596 of file utils.cpp.

597{
598 WCHAR szCmd[MAX_PATH * 2];
599 DWORD cb = sizeof(szCmd);
601 if (error)
604}
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
EXTERN_C LSTATUS WINAPI RegGetValueW(HKEY, LPCWSTR, LPCWSTR, DWORD, LPDWORD, PVOID, LPDWORD)
Definition: reg.c:1931
static HRESULT ShellExecuteCommand(_In_opt_ HWND hWnd, _In_ PCWSTR Command, _In_opt_ UINT Flags)
Definition: utils.cpp:572
#define SEE_MASK_FLAG_LOG_USAGE
Definition: shellapi.h:55
#define RRF_RT_REG_SZ
Definition: winreg.h:58

Referenced by RunIndirectRegCommand().

◆ SHDialogBox()

EXTERN_C INT_PTR WINAPI SHDialogBox ( _In_opt_ HINSTANCE  hInstance,
_In_ PCSTR  lpTemplateName,
_In_opt_ HWND  hWndParent,
_In_opt_ SHDIALOGPROC  fn,
_In_opt_ PVOID  pThis 
)

Definition at line 895 of file utils.cpp.

901{
902 SHDIALOG data = { fn, pThis };
903 return DialogBoxParamA(hInstance, lpTemplateName, hWndParent, SHDialogProc, (LPARAM)&data);
904}
HINSTANCE hInstance
Definition: charmap.c:19
static INT_PTR CALLBACK SHDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: utils.cpp:841
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LONG_PTR LPARAM
Definition: minwindef.h:175
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
INT_PTR WINAPI DialogBoxParamA(_In_opt_ HINSTANCE, _In_ LPCSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

◆ SHDialogProc()

static INT_PTR CALLBACK SHDialogProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 841 of file utils.cpp.

842{
845 HWND hwndItem;
846 LRESULT ret;
847
848 if (uMsg == WM_INITDIALOG)
849 {
852 lParam = (LPARAM)pData->pThis;
853 }
854 else
855 {
857 }
858
859 if (pData && pData->fn)
860 {
861 result = pData->fn(pData->pThis, hWnd, uMsg, wParam, lParam);
862 if (result)
863 return result;
864 }
865
866 switch (uMsg)
867 {
868 case WM_INITDIALOG:
869 return TRUE;
870
871 case WM_COMMAND:
872 if (LOWORD(wParam) == IDHELP)
873 return FALSE;
874
875 hwndItem = GetDlgItem(hWnd, LOWORD(wParam));
876 if (!hwndItem)
877 return FALSE;
878
879 ret = SendMessageA(hwndItem, WM_GETDLGCODE, 0, 0);
881 return FALSE;
882
884 return TRUE;
885
886 default:
887 return FALSE;
888 }
889}
WPARAM wParam
Definition: combotst.c:138
struct tagSHDIALOG * PSHDIALOG
GLuint64EXT * result
Definition: glext.h:11304
LONG_PTR LRESULT
Definition: minwindef.h:176
#define LOWORD(l)
Definition: pedump.c:82
#define IDHELP
Definition: resource_2.h:8
int32_t INT_PTR
Definition: typedefs.h:64
#define SetWindowLongPtrA
Definition: winuser.h:5511
#define DWLP_USER
Definition: winuser.h:883
#define WM_COMMAND
Definition: winuser.h:1768
#define DLGC_UNDEFPUSHBUTTON
Definition: winuser.h:2658
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GetWindowLongPtrA
Definition: winuser.h:4982
#define WM_INITDIALOG
Definition: winuser.h:1767
#define DLGC_DEFPUSHBUTTON
Definition: winuser.h:2657
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_GETDLGCODE
Definition: winuser.h:1717
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SHDialogBox().

◆ ShellExecuteCommand()

static HRESULT ShellExecuteCommand ( _In_opt_ HWND  hWnd,
_In_ PCWSTR  Command,
_In_opt_ UINT  Flags 
)
static

Definition at line 572 of file utils.cpp.

573{
574 WCHAR szCmd[MAX_PATH * 2];
576 if (len <= 0) // Could not resolve the command, just use the input
577 {
578 HRESULT hr = StringCchCopyW(szCmd, _countof(szCmd), Command);
579 if (FAILED(hr))
580 return hr;
581 }
582 PWSTR pszArgs = PathGetArgsW(szCmd);
583 PathRemoveArgsW(szCmd);
584 PathUnquoteSpacesW(szCmd);
585
586 SHELLEXECUTEINFOW sei = { sizeof(sei), Flags, hWnd, NULL, szCmd, pszArgs };
587 sei.nShow = SW_SHOW;
590}
void WINAPI PathUnquoteSpacesW(WCHAR *path)
Definition: path.c:1982
WCHAR *WINAPI PathGetArgsW(const WCHAR *path)
Definition: path.c:1716
void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
Definition: path.c:782
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2723
#define PPCF_FORCEQUALIFY
Definition: shlobj.h:2429
LONG WINAPI PathProcessCommand(_In_ LPCWSTR, _Out_writes_(cchDest) LPWSTR, int cchDest, DWORD)
#define PPCF_ADDARGUMENTS
Definition: shlobj.h:2426
Definition: shell.h:41
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SW_SHOW
Definition: winuser.h:786
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by RunRegCommand().

◆ SHGetFileDescriptionA()

BOOL WINAPI SHGetFileDescriptionA ( _In_ PCSTR  pszPath,
_In_opt_ PCSTR  pszVerKey,
_In_opt_ PCSTR  pszDisplayName,
_Out_opt_ PSTR  pszOut,
_Inout_ PUINT  pcchOut 
)

Definition at line 1198 of file utils.cpp.

1204{
1205 WCHAR szPathW[MAX_PATH], szVerKeyW[MAX_PATH], szDisplayNameW[MAX_PATH], szOutW[MAX_PATH];
1206 CHAR szOutA[MAX_PATH];
1207 BOOL ret;
1208 UINT cchOutW;
1209
1210 SHAnsiToUnicode(pszPath, szPathW, _countof(szPathW));
1211 szPathW[_countof(szPathW) - 1] = UNICODE_NULL;
1212
1213 if (pszVerKey)
1214 {
1215 SHAnsiToUnicode(pszVerKey, szVerKeyW, _countof(szVerKeyW));
1216 szVerKeyW[_countof(szVerKeyW) - 1] = UNICODE_NULL;
1217 }
1218
1219 if (pszDisplayName)
1220 {
1221 SHAnsiToUnicode(pszDisplayName, szDisplayNameW, _countof(szDisplayNameW));
1222 szDisplayNameW[_countof(szDisplayNameW) - 1] = UNICODE_NULL;
1223 }
1224
1225 cchOutW = (UINT)_countof(szOutW);
1226 ret = SHGetFileDescriptionW(szPathW, (pszVerKey ? szVerKeyW : NULL),
1227 (pszDisplayName ? szDisplayNameW : NULL), szOutW, &cchOutW);
1228 if (ret)
1229 {
1230 szOutW[_countof(szOutW) - 1] = UNICODE_NULL;
1231
1232 if (!pszOut)
1233 pszOut = szOutA;
1234
1235 SHUnicodeToAnsi(szOutW, pszOut, *pcchOut);
1236 if (*pcchOut > 0)
1237 pszOut[*pcchOut - 1] = ANSI_NULL;
1238 *pcchOut = lstrlenA(pszOut) + 1;
1239 }
1240
1241 return ret;
1242}
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2803
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2927
BOOL WINAPI SHGetFileDescriptionW(_In_ PCWSTR pszPath, _In_opt_ PCWSTR pszVerKey, _In_opt_ PCWSTR pszDisplayName, _Out_opt_ PWSTR pszOut, _Inout_ PUINT pcchOut)
Definition: utils.cpp:1086
unsigned int BOOL
Definition: ntddk_ex.h:94

◆ SHGetFileDescriptionW()

BOOL WINAPI SHGetFileDescriptionW ( _In_ PCWSTR  pszPath,
_In_opt_ PCWSTR  pszVerKey,
_In_opt_ PCWSTR  pszDisplayName,
_Out_opt_ PWSTR  pszOut,
_Inout_ PUINT  pcchOut 
)

Definition at line 1086 of file utils.cpp.

1092{
1093 DWORD pdwAttrs = 0;
1094 if (!PathFileExistsAndAttributesW(pszPath, &pdwAttrs))
1095 return FALSE;
1096
1099
1100 PVOID pvDescription = NULL;
1101 UINT cchDescription = 0;
1102 PVOID pvBlock = NULL;
1103
1104 BOOL bIsFile = !(pdwAttrs & FILE_ATTRIBUTE_DIRECTORY) &&
1105 !PathIsUNCServerW(pszPath) &&
1106 !PathIsUNCServerShareW(pszPath);
1107 if (bIsFile)
1108 {
1109 DWORD dwHandle = 0;
1110 DWORD cbBlock = GetFileVersionInfoSizeW(szPath, &dwHandle);
1111 if (cbBlock)
1112 {
1113 pvBlock = LocalAlloc(LPTR, cbBlock);
1114 if (pvBlock && GetFileVersionInfoW(szPath, dwHandle, cbBlock, pvBlock))
1115 {
1116 WCHAR szSubBlock[60];
1117 BOOL ret = FALSE;
1118 if (pszVerKey)
1119 {
1120 StringCchCopyW(szSubBlock, _countof(szSubBlock), pszVerKey);
1121 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1122 }
1123
1124 if (!ret)
1125 {
1126 PVOID pTranslation = NULL;
1127 UINT cbTranslation = 0;
1128 if (VerQueryValueW(pvBlock, L"\\VarFileInfo\\Translation", &pTranslation,
1129 &cbTranslation) && cbTranslation)
1130 {
1131 UINT langId = ((PWORD)pTranslation)[0];
1132 UINT codePage = ((PWORD)pTranslation)[1];
1133 StringCchPrintfW(szSubBlock, _countof(szSubBlock),
1134 L"\\StringFileInfo\\%04X%04X\\FileDescription",
1135 langId, codePage);
1136 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1137 }
1138 }
1139
1140 if (!ret)
1141 {
1142 // 0x0409: English (United States), 0x04B0: UTF-16 codepage
1143 StringCchCopyW(szSubBlock, _countof(szSubBlock),
1144 L"\\StringFileInfo\\040904B0\\FileDescription");
1145 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1146 }
1147 if (!ret)
1148 {
1149 // 0x0409: English (United States), 0x04E4: Latin 1 codepage
1150 StringCchCopyW(szSubBlock, _countof(szSubBlock),
1151 L"\\StringFileInfo\\040904E4\\FileDescription");
1152 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1153 }
1154 if (!ret)
1155 {
1156 // 0x0409: English (United States), 0x0000: Neutral
1157 StringCchCopyW(szSubBlock, _countof(szSubBlock),
1158 L"\\StringFileInfo\\04090000\\FileDescription");
1159 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1160 }
1161 }
1162 }
1163 }
1164
1165 PWSTR pszDescription = (PWSTR)pvDescription;
1166 if (!pszDescription || !*pszDescription)
1167 {
1169 pszDescription = PathFindFileNameW(szPath);
1170 cchDescription = lstrlenW(pszDescription);
1171 }
1172
1173 PrettifyFileDescriptionW(pszDescription, pszDisplayName);
1174
1175 UINT cchResult = lstrlenW(pszDescription) + 1;
1176 if (pszOut)
1177 {
1178 UINT cchCopy = min(cchResult, *pcchOut);
1179 StringCchCopyW(pszOut, cchCopy, pszDescription);
1180 *pcchOut = cchCopy;
1181 }
1182 else
1183 {
1184 *pcchOut = cchResult;
1185 }
1186
1187 if (pvBlock)
1188 LocalFree(pvBlock);
1189
1190 return TRUE;
1191}
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1922
BOOL WINAPI PathIsUNCServerShareW(const WCHAR *path)
Definition: path.c:1040
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
BOOL WINAPI PathIsUNCServerW(const WCHAR *path)
Definition: path.c:1852
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:967
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1171
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:738
VOID WINAPI PrettifyFileDescriptionW(_Inout_ PWSTR pszTarget, _In_opt_ PCWSTR pszCutList)
Definition: utils.cpp:1043
LPCWSTR szPath
Definition: env.c:37
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
WORD * PWORD
Definition: pedump.c:67

Referenced by SHGetFileDescriptionA().

◆ SHInvokeCommandOnContextMenu()

EXTERN_C HRESULT WINAPI SHInvokeCommandOnContextMenu ( _In_opt_ HWND  hWnd,
_In_opt_ IUnknown pUnk,
_In_ IContextMenu pCM,
_In_ UINT  fCMIC,
_In_opt_ LPCSTR  pszVerb 
)

Definition at line 409 of file utils.cpp.

415{
416 return SHInvokeCommandOnContextMenuEx(hWnd, pUnk, pCM, fCMIC, CMF_EXTENDEDVERBS, pszVerb, NULL);
417}
EXTERN_C HRESULT WINAPI SHInvokeCommandOnContextMenuEx(_In_opt_ HWND hWnd, _In_opt_ IUnknown *pUnk, _In_ IContextMenu *pCM, _In_ UINT fCMIC, _In_ UINT fCMF, _In_opt_ LPCSTR pszVerb, _In_opt_ LPCWSTR pwszDir)
Definition: utils.cpp:392
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by BrFolder_Delete().

◆ SHInvokeCommandOnContextMenuEx()

EXTERN_C HRESULT WINAPI SHInvokeCommandOnContextMenuEx ( _In_opt_ HWND  hWnd,
_In_opt_ IUnknown pUnk,
_In_ IContextMenu pCM,
_In_ UINT  fCMIC,
_In_ UINT  fCMF,
_In_opt_ LPCSTR  pszVerb,
_In_opt_ LPCWSTR  pwszDir 
)

Definition at line 392 of file utils.cpp.

400{
401 return SHInvokeCommandOnContextMenuInternal(hWnd, pUnk, pCM, fCMIC, fCMF, pszVerb, pwszDir, true);
402}

Referenced by SHInvokeCommandOnContextMenu(), and SHInvokeCommandWithFlagsAndSite().

◆ SHInvokeCommandOnContextMenuInternal()

static HRESULT SHInvokeCommandOnContextMenuInternal ( _In_opt_ HWND  hWnd,
_In_opt_ IUnknown pUnk,
_In_ IContextMenu pCM,
_In_ UINT  fCMIC,
_In_ UINT  fCMF,
_In_opt_ LPCSTR  pszVerb,
_In_opt_ LPCWSTR  pwszDir,
_In_ bool  ForceQCM 
)
static

Definition at line 304 of file utils.cpp.

313{
314 CMINVOKECOMMANDINFOEX info = { sizeof(info), fCMIC, hWnd, pszVerb };
315 INT iDefItem = 0;
316 HMENU hMenu = NULL;
317 HCURSOR hOldCursor;
318 HRESULT hr = S_OK;
319 WCHAR wideverb[MAX_PATH];
320
321 if (!pCM)
322 return E_INVALIDARG;
323
324 hOldCursor = SetCursor(LoadCursorW(NULL, (LPCWSTR)IDC_WAIT));
325 info.nShow = SW_NORMAL;
326 if (pUnk)
328
329 if (IS_INTRESOURCE(pszVerb))
330 {
331 hMenu = CreatePopupMenu();
332 if (hMenu)
333 {
334 hr = pCM->QueryContextMenu(hMenu, 0, 1, MAXSHORT, fCMF | CMF_DEFAULTONLY);
335 iDefItem = GetMenuDefaultItem(hMenu, 0, 0);
336 if (iDefItem != -1)
337 info.lpVerb = MAKEINTRESOURCEA(iDefItem - 1);
338 }
339 info.lpVerbW = MAKEINTRESOURCEW(info.lpVerb);
340 }
341 else
342 {
344 {
345 info.fMask |= CMF_OPTIMIZEFORINVOKE;
346 }
347 if (pszVerb && SHAnsiToUnicode(pszVerb, wideverb, _countof(wideverb)))
348 {
349 info.fMask |= CMIC_MASK_UNICODE;
350 info.lpVerbW = wideverb;
351 }
352 if (ForceQCM)
353 {
354 hMenu = CreatePopupMenu();
355 hr = pCM->QueryContextMenu(hMenu, 0, 1, MAXSHORT, fCMF);
356 }
357 }
358
359 SetCursor(hOldCursor);
360
361 if (!FAILED_UNEXPECTEDLY(hr) && (iDefItem != -1 || info.lpVerb))
362 {
363 if (!hWnd)
364 info.fMask |= CMIC_MASK_FLAG_NO_UI;
365
367 if (pwszDir)
368 {
369 info.fMask |= CMIC_MASK_UNICODE;
370 info.lpDirectoryW = pwszDir;
371 if (SHUnicodeToAnsi(pwszDir, dir, _countof(dir)))
372 info.lpDirectory = dir;
373 }
374
375 hr = pCM->InvokeCommand((LPCMINVOKECOMMANDINFO)&info);
376 if (FAILED_UNEXPECTEDLY(hr)) { /* Diagnostic message */ }
377 }
378
379 if (pUnk)
381 if (hMenu)
382 DestroyMenu(hMenu);
383
384 return hr;
385}
unsigned int dir
Definition: maze.c:112
#define E_INVALIDARG
Definition: ddrawi.h:101
#define IS_INTRESOURCE(x)
Definition: loader.c:613
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1411
static WORD GetVersionMajorMinor()
Definition: utils.cpp:40
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define MAXSHORT
Definition: umtypes.h:114
HICON HCURSOR
Definition: windef.h:99
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2474
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define IDC_WAIT
Definition: winuser.h:697
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SW_NORMAL
Definition: winuser.h:780

Referenced by IContextMenu_Invoke(), and SHInvokeCommandOnContextMenuEx().

◆ SHInvokeCommandsOnContextMenu()

EXTERN_C HRESULT WINAPI SHInvokeCommandsOnContextMenu ( _In_opt_ HWND  hwnd,
_In_opt_ IUnknown punkSite,
_In_ IContextMenu pCM,
_In_ DWORD  fMask,
_In_reads_opt_(cVerbs) PCSTR pVerbs,
_In_ UINT  cVerbs 
)

Definition at line 435 of file utils.cpp.

442{
443 HRESULT hr;
444 CMINVOKECOMMANDINFOEX ici;
445 WCHAR szVerbW[MAX_PATH];
446 HMENU hMenu = NULL;
447 UINT iVerb, idDefault = (UINT)-1;
448 PCSTR pszVerbA = NULL;
449
450 if (!pCM)
451 return E_INVALIDARG;
452
453 hMenu = CreatePopupMenu();
454 if (!hMenu)
455 return E_OUTOFMEMORY;
456
457 if (punkSite)
458 IUnknown_SetSite(pCM, punkSite);
459
460 hr = pCM->QueryContextMenu(hMenu, 0, 1, MAXSHORT, (cVerbs ? 0 : CMF_DEFAULTONLY));
461 if (FAILED(hr))
462 goto Cleanup;
463
464 if (!cVerbs)
465 {
466 idDefault = GetMenuDefaultItem(hMenu, FALSE, 0);
467 if (idDefault != (UINT)-1)
468 pszVerbA = MAKEINTRESOURCEA(idDefault - 1);
469 }
470
471 ZeroMemory(&ici, sizeof(ici));
472 ici.cbSize = sizeof(ici);
473 ici.hwnd = hwnd;
474 ici.nShow = SW_SHOWNORMAL;
475
476 iVerb = 0;
477 do
478 {
479 if (cVerbs)
480 pszVerbA = pVerbs[iVerb];
481
482 if (!pszVerbA && idDefault == (UINT)-1)
483 {
484 hr = E_FAIL;
485 break;
486 }
487
488 ici.fMask = fMask;
489 ici.lpVerb = pszVerbA;
490 ici.lpVerbW = NULL;
491
492 if (idDefault == (UINT)-1 && !IS_INTRESOURCE(pszVerbA) && IsTextAsciiOnly(pszVerbA))
493 {
494 size_t ich;
495 for (ich = 0; pszVerbA[ich] && ich + 1 < _countof(szVerbW); ++ich)
496 {
497 szVerbW[ich] = (BYTE)pszVerbA[ich];
498 }
499 szVerbW[ich] = UNICODE_NULL;
500
501 ici.lpVerbW = szVerbW;
502 ici.fMask |= CMIC_MASK_UNICODE;
503 }
504
505 hr = pCM->InvokeCommand((LPCMINVOKECOMMANDINFO)&ici);
506
508 break;
509
510 ++iVerb;
511 } while (iVerb < cVerbs);
512
513Cleanup:
514 if (punkSite)
516 DestroyMenu(hMenu);
517 return hr;
518}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
static BOOL IsTextAsciiOnly(PCSTR psz)
Definition: utils.cpp:420
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERROR_CANCELLED
Definition: winerror.h:1055
#define SW_SHOWNORMAL
Definition: winuser.h:781
unsigned char BYTE
Definition: xxhash.c:193

◆ SHInvokeCommandWithFlagsAndSite()

EXTERN_C HRESULT WINAPI SHInvokeCommandWithFlagsAndSite ( _In_opt_ HWND  hWnd,
_In_opt_ IUnknown pUnk,
_In_ IShellFolder pShellFolder,
_In_ LPCITEMIDLIST  pidl,
_In_ UINT  fCMIC,
_In_opt_ LPCSTR  pszVerb 
)

Definition at line 525 of file utils.cpp.

532{
534 if (pShellFolder)
535 {
536 IContextMenu *pCM;
537 hr = pShellFolder->GetUIObjectOf(hWnd, 1, &pidl, IID_IContextMenu, NULL, (void**)&pCM);
538 if (SUCCEEDED(hr))
539 {
540 fCMIC |= CMIC_MASK_FLAG_LOG_USAGE;
541 hr = SHInvokeCommandOnContextMenuEx(hWnd, pUnk, pCM, fCMIC, 0, pszVerb, NULL);
542 pCM->Release();
543 }
544 }
545 return hr;
546}

◆ SHLWAPI_IsBogusHRESULT()

static BOOL SHLWAPI_IsBogusHRESULT ( HRESULT  hr)
inlinestatic

Definition at line 690 of file utils.cpp.

691{
692 return (hr == E_FAIL || hr == E_INVALIDARG || hr == E_NOTIMPL);
693}
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by IShellFolder_GetDisplayNameOf().

◆ SHRunIndirectRegClientCommand()

EXTERN_C HRESULT WINAPI SHRunIndirectRegClientCommand ( _In_opt_ HWND  hWnd,
_In_ PCWSTR  pszClientType 
)

Definition at line 625 of file utils.cpp.

626{
627 WCHAR szKey[MAX_PATH], szClient[MAX_PATH];
628 HRESULT hr = StringCchPrintfW(szKey, _countof(szKey), L"Software\\Clients\\%s", pszClientType);
629 if (FAILED(hr))
630 return hr;
631
632 // Find the default client
633 DWORD error, cb;
634 cb = sizeof(szClient);
636 if (error)
637 {
638 cb = sizeof(szClient);
641 if (error)
643 }
644
645 hr = StringCchPrintfW(szKey, _countof(szKey), L"Software\\Clients\\%s\\%s", pszClientType, szClient);
646 if (SUCCEEDED(hr))
648 return hr;
649}
EXTERN_C HRESULT WINAPI RunIndirectRegCommand(_In_opt_ HWND hWnd, _In_ HKEY hKey, _In_opt_ PCWSTR pszSubKey, _In_ PCWSTR pszVerb)
Definition: utils.cpp:610
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:307
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by CTaskSwitchWnd::InvokeRegistryAppKeyCommand().

◆ UnExpandEnvironmentStringForUserA()

static BOOL UnExpandEnvironmentStringForUserA ( _In_ HANDLE  hUserToken,
_In_ PCSTR  lpString,
_In_ PCSTR  lpSrc,
_Out_ PSTR  pszDest,
_In_ INT  cchDest 
)
static

Definition at line 47 of file utils.cpp.

53{
54 CHAR szBuff[MAX_PATH];
55 INT cchExpanded;
56
57 if (hUserToken)
58 {
59 if (ExpandEnvironmentStringsForUserA(hUserToken, lpSrc, szBuff, _countof(szBuff)))
60 cchExpanded = lstrlenA(szBuff) + 1;
61 else
62 cchExpanded = 0;
63 }
64 else
65 {
66 cchExpanded = ExpandEnvironmentStringsA(lpSrc, szBuff, _countof(szBuff));
67 }
68
69 if (!cchExpanded || cchExpanded > cchDest)
70 return FALSE;
71
72 INT cchEnvPath = cchExpanded - 1;
74 szBuff, cchEnvPath, lpString, cchEnvPath) != CSTR_EQUAL)
75 {
76 return FALSE;
77 }
78
79 INT cchSuffix = lstrlenA(lpString) - cchEnvPath;
80 if (lstrlenA(lpSrc) + cchSuffix >= cchDest)
81 return FALSE;
82
83 StringCchCopyA(pszDest, cchDest, lpSrc);
84 StringCchCatA(pszDest, cchDest, &lpString[cchEnvPath]);
85 return TRUE;
86}
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:372
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: locale.c:4015
BOOL WINAPI ExpandEnvironmentStringsForUserA(IN HANDLE hToken, IN LPCSTR lpSrc, OUT LPSTR lpDest, IN DWORD dwSize)
Definition: environment.c:794
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
#define NORM_IGNORECASE
Definition: winnls.h:191
#define CSTR_EQUAL
Definition: winnls.h:510

Referenced by PathUnExpandEnvStringsForUserA().

◆ UnExpandEnvironmentStringForUserW()

static BOOL UnExpandEnvironmentStringForUserW ( _In_ HANDLE  hUserToken,
_In_ PCWSTR  lpString,
_In_ PCWSTR  lpSrc,
_Out_ PWSTR  pszDest,
_In_ INT  cchDest 
)
static

Definition at line 89 of file utils.cpp.

95{
96 WCHAR szBuff[MAX_PATH];
97 INT cchExpanded;
98
99 if (hUserToken)
100 {
101 if (ExpandEnvironmentStringsForUserW(hUserToken, lpSrc, szBuff, _countof(szBuff)))
102 cchExpanded = lstrlenW(szBuff) + 1;
103 else
104 cchExpanded = 0;
105 }
106 else
107 {
108 cchExpanded = ExpandEnvironmentStringsW(lpSrc, szBuff, _countof(szBuff));
109 }
110
111 if (!cchExpanded || cchExpanded > cchDest)
112 return FALSE;
113
114 INT cchEnvPath = cchExpanded - 1;
116 szBuff, cchEnvPath, lpString, cchEnvPath) != CSTR_EQUAL)
117 {
118 return FALSE;
119 }
120
121 INT cchSuffix = lstrlenW(lpString) - cchEnvPath;
122 if (lstrlenW(lpSrc) + cchSuffix >= cchDest)
123 return FALSE;
124
125 StringCchCopyW(pszDest, cchDest, lpSrc);
126 StringCchCatW(pszDest, cchDest, &lpString[cchEnvPath]);
127 return TRUE;
128}
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:3946
BOOL WINAPI ExpandEnvironmentStringsForUserW(IN HANDLE hToken, IN LPCWSTR lpSrc, OUT LPWSTR lpDest, IN DWORD dwSize)
Definition: environment.c:743
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325

Referenced by PathUnExpandEnvStringsForUserW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ g_RetryData

const RETRY_DATA g_RetryData[]
static
Initial value:
=
{
{ SHGDN_FOREDITING, SHGDN_NORMAL, SFGDNO_RETRYALWAYS },
{ SHGDN_FORADDRESSBAR, SHGDN_NORMAL, SFGDNO_RETRYALWAYS },
{ SHGDN_NORMAL, SHGDN_FORPARSING, SFGDNO_RETRYALWAYS },
{ SHGDN_FORPARSING, SHGDN_NORMAL, SFGDNO_RETRYWITHFORPARSING },
{ SHGDN_INFOLDER, SHGDN_NORMAL, SFGDNO_RETRYALWAYS },
}

Definition at line 702 of file utils.cpp.

Referenced by IShellFolder_GetDisplayNameOf().