ReactOS 0.4.17-dev-357-ga8f14ff
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 "resource.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)
 
EXTERN_C INT WINAPI SHRestrictedMessageBox (_In_ HWND hWnd)
 
EXTERN_C ULONG WINAPI GetProcessOsVersion (void)
 

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

992{
993 *ppszOut = NULL;
994
997 if (error)
999
1000 PWSTR pszData = (PWSTR)LocalAlloc(LPTR, cbData);
1001 if (!pszData)
1003
1004 error = SHGetValueW(hkey, pszSubKey, pszValue, NULL, pszData, &cbData);
1005 if (error)
1006 {
1007 LocalFree(pszData);
1008 return HRESULT_FROM_WIN32(error);
1009 }
1010
1011 *ppszOut = pszData;
1012 return S_OK;
1013}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
DWORD WINAPI SHGetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len)
Definition: main.c:2222
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 275 of file utils.cpp.

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

◆ CharLowerNoDBCSAWorker()

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

Definition at line 246 of file utils.cpp.

247{
248 CHAR szBuff[MAX_PATH];
249 INT cch;
250 if (!lpString)
251 return FALSE;
252 cch = cchMax ? cchMax : lstrlenA(lpString);
253 if (FAILED(StringCchCopyA(szBuff, _countof(szBuff), lpString)))
254 return FALSE;
256 szBuff, cch, lpString, cch);
257}
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 283 of file utils.cpp.

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

◆ CharLowerNoDBCSWWorker()

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

Definition at line 259 of file utils.cpp.

260{
261 WCHAR szDest[MAX_PATH];
262 INT cch;
263 if (!lpString)
264 return FALSE;
265 cch = cchMax ? cchMax : lstrlenW(lpString);
266 if (FAILED(StringCchCopyW(szDest, _countof(szDest), lpString)))
267 return FALSE;
269 szDest, cch, lpString, cch);
270}
#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 291 of file utils.cpp.

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

◆ CharUpperNoDBCSW()

EXTERN_C PWSTR WINAPI CharUpperNoDBCSW ( _Inout_ PWSTR  lpString)

Definition at line 299 of file utils.cpp.

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

◆ GetProcessOsVersion()

EXTERN_C ULONG WINAPI GetProcessOsVersion ( void  )

Definition at line 1257 of file utils.cpp.

1258{
1259 PPEB Peb = NtCurrentTeb()->Peb;
1260 return (Peb->OSMajorVersion << 8) | Peb->OSMinorVersion;
1261}
PPEB Peb
Definition: dllmain.c:27
#define NtCurrentTeb
ULONG OSMinorVersion
Definition: ntddk_ex.h:301
ULONG OSMajorVersion
Definition: ntddk_ex.h:300

Referenced by CBasePropertyBag::QueryInterface(), CMemPropertyBag::Read(), and CMemPropertyBag::Write().

◆ GetVersionMajorMinor()

static WORD GetVersionMajorMinor ( )
inlinestatic

Definition at line 41 of file utils.cpp.

42{
45}
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 557 of file utils.cpp.

562{
563 TRACE("(%p, %p, %s, %u)\n", pContextMenu, hwnd, debugstr_a(lpVerb), uFlags);
565 uFlags, lpVerb, NULL, false);
566 return !FAILED_UNEXPECTEDLY(hr);
567}
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:305
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
#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 808 of file utils.cpp.

813{
814 TRACE("(%p, %p, %p, %p)\n", psf, lParam, pidl1, pidl2);
815
816 if (lParam & ~(SIZE_T)SHCIDS_COLUMNMASK)
817 {
818 /* Try as IShellFolder2 if possible */
819 HRESULT hr = psf->QueryInterface(IID_IShellFolder2, (void **)&psf);
820 if (FAILED(hr))
821 lParam &= SHCIDS_COLUMNMASK;
822 else
823 psf->Release();
824 }
825
826 return psf->CompareIDs(lParam, pidl1, pidl2);
827}
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 720 of file utils.cpp.

726{
727 HRESULT hr;
728
729 TRACE("(%p)->(%p, 0x%lX, %p, 0x%lX)\n", psf, pidl, uFlags, lpName, dwRetryFlags);
730
731 hr = psf->GetDisplayNameOf(pidl, uFlags, lpName);
733 return hr;
734
735 dwRetryFlags |= SFGDNO_RETRYALWAYS;
736
737 if ((uFlags & SHGDN_FORPARSING) == 0)
738 dwRetryFlags |= SFGDNO_RETRYWITHFORPARSING;
739
740 // Retry with other flags to get successful results
741 for (SIZE_T iEntry = 0; iEntry < _countof(g_RetryData); ++iEntry)
742 {
743 const RETRY_DATA *pData = &g_RetryData[iEntry];
744 if (!(dwRetryFlags & pData->dwRetryFlags))
745 continue;
746
747 SHGDNF uNewFlags = ((uFlags & ~pData->uRemove) | pData->uAdd);
748 if (uNewFlags == uFlags)
749 continue;
750
751 hr = psf->GetDisplayNameOf(pidl, uNewFlags, lpName);
753 break;
754
755 uFlags = uNewFlags; // Update flags every time
756 }
757
758 return hr;
759}
static const RETRY_DATA g_RetryData[]
Definition: utils.cpp:703
static BOOL SHLWAPI_IsBogusHRESULT(HRESULT hr)
Definition: utils.cpp:691
#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 768 of file utils.cpp.

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

◆ IsTextAsciiOnly()

static BOOL IsTextAsciiOnly ( PCSTR  psz)
inlinestatic

Definition at line 421 of file utils.cpp.

422{
423 for (const signed char *pch = (const signed char *)psz; *pch; ++pch)
424 {
425 if (*pch < 0)
426 return FALSE;
427 }
428 return TRUE;
429}
#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 1021 of file utils.cpp.

1025{
1027 HRESULT hr = IUnknown_QueryServiceForWebBrowserApp(punk, IID_IWebBrowser2, (PVOID*)&pWB2);
1028 if (FAILED(hr))
1029 return hr;
1030
1031 WCHAR szGUID[40];
1032 StringFromGUID2(rguid, szGUID, _countof(szGUID));
1033
1034 CComVariant varClsid(szGUID), varShow((bool)!!bShow), varSize;
1035 return pWB2->ShowBrowserBar(&varClsid, &varShow, &varSize);
1036}
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:4814
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158

◆ MapWin32ErrorToSTG()

EXTERN_C HRESULT WINAPI MapWin32ErrorToSTG ( _In_ HRESULT  hr)

Definition at line 229 of file utils.cpp.

230{
231 switch (hr)
232 {
241 default:
242 return hr;
243 }
244}
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 913 of file utils.cpp.

917{
918 if (!pszStart)
919 return NULL;
920
921 PCSTR pchStart = pszStart;
922 while (*pchStart == ';')
923 ++pchStart;
924
925 if (!*pchStart)
926 return NULL;
927
928 PSTR pchEnd = StrChrA(pchStart, ';');
929 if (!pchEnd)
930 pchEnd = (PSTR)(pchStart + lstrlenA(pchStart));
931
932 const UINT cchSegment = (UINT)(pchEnd - pchStart);
933 const UINT cchToCopy = min(cchSegment + 1, cchDest);
934 lstrcpynA(pszDest, pchStart, cchToCopy);
935 pszDest[cchSegment] = ANSI_NULL;
936
937 PathRemoveBlanksA(pszDest);
938 if (!*pszDest)
939 return NULL;
940
941 return (*pchEnd == ';') ? (pchEnd + 1) : pchEnd;
942}
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 955 of file utils.cpp.

959{
960 if (!pszStart)
961 return NULL;
962
963 PCWSTR pchStart = pszStart;
964 while (*pchStart == L';')
965 ++pchStart;
966
967 if (!*pchStart)
968 return NULL;
969
970 PWSTR pchEnd = StrChrW(pchStart, L';');
971 if (!pchEnd)
972 pchEnd = (PWSTR)(pchStart + lstrlenW(pchStart));
973
974 const UINT cchSegment = (UINT)(pchEnd - pchStart);
975 const UINT cchToCopy = min(cchSegment + 1, cchDest);
976 lstrcpynW(pszDest, pchStart, cchToCopy);
977 pszDest[cchSegment] = UNICODE_NULL;
978
979 PathRemoveBlanksW(pszDest);
980 if (!*pszDest)
981 return NULL;
982
983 return (*pchEnd == L';') ? (pchEnd + 1) : pchEnd;
984}
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 661 of file utils.cpp.

665{
666 TRACE("(%s, 0x%lX, %p)\n", debugstr_w(pszPath), dwWhich, pdwFileAttributes);
667
668 if (pdwFileAttributes)
669 *pdwFileAttributes = INVALID_FILE_ATTRIBUTES;
670
671 if (!pszPath)
672 return FALSE;
673
674 if (!dwWhich || (*PathFindExtensionW(pszPath) && (dwWhich & WHICH_OPTIONAL)))
675 return PathFileExistsAndAttributesW(pszPath, pdwFileAttributes);
676
677 if (!PathFileExistsDefExtW(pszPath, dwWhich))
678 {
679 if (pdwFileAttributes)
680 *pdwFileAttributes = INVALID_FILE_ATTRIBUTES;
681 return FALSE;
682 }
683
684 if (pdwFileAttributes)
685 *pdwFileAttributes = GetFileAttributesW(pszPath);
686
687 return TRUE;
688}
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:747
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:170
#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 138 of file utils.cpp.

143{
144 static const PCSTR c_varsA[] =
145 {
146 "%APPDATA%",
147 "%USERPROFILE%",
148 "%ALLUSERSPROFILE%",
149 "%ProgramFiles%",
150 "%SystemRoot%",
151 "%SystemDrive%",
152 };
153
154 if (!pszPath)
155 {
156 if (pszBuff && cchBuff)
157 *pszBuff = ANSI_NULL;
158
159 return FALSE;
160 }
161
162 if (!pszBuff)
163 return FALSE;
164
165 for (size_t iVar = 0; iVar < _countof(c_varsA); ++iVar)
166 {
167 if (UnExpandEnvironmentStringForUserA(hUserToken, pszPath, c_varsA[iVar],
168 pszBuff, cchBuff))
169 {
170 return TRUE;
171 }
172 }
173
174 return FALSE;
175}
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:48

◆ PathUnExpandEnvStringsForUserW()

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

Definition at line 184 of file utils.cpp.

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

◆ PrettifyFileDescriptionW()

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

Definition at line 1044 of file utils.cpp.

1045{
1046 if (!pszTarget || !*pszTarget)
1047 return;
1048
1049 PWSTR pszFreeList = NULL;
1050 PCWSTR pszList = pszCutList;
1051 PCWSTR pszAssoc = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileAssociation";
1052 if (_AllocValueString(HKEY_LOCAL_MACHINE, pszAssoc, L"CutList", &pszFreeList) == S_OK)
1053 pszList = pszFreeList;
1054
1055 if (pszList && *pszList)
1056 {
1057 for (PCWSTR pszEntry = pszList; *pszEntry; pszEntry += lstrlenW(pszEntry) + 1)
1058 {
1059 PWSTR pszMatch = StrRStrIW(pszTarget, NULL, pszEntry);
1060 if (!pszMatch)
1061 continue;
1062
1063 if (pszMatch[lstrlenW(pszEntry)])
1064 continue;
1065
1066 *pszMatch = UNICODE_NULL;
1067 while (pszMatch > pszTarget && pszMatch[-1] == L' ')
1068 {
1069 --pszMatch;
1070 *pszMatch = UNICODE_NULL;
1071 }
1072
1073 break;
1074 }
1075 }
1076
1077 if (pszFreeList)
1078 LocalFree(pszFreeList);
1079}
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:987
#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 611 of file utils.cpp.

612{
613 WCHAR szKey[MAX_PATH];
614 HRESULT hr;
615 if (pszSubKey)
616 hr = StringCchPrintfW(szKey, _countof(szKey), L"%s\\shell\\%s\\command", pszSubKey, pszVerb);
617 else
618 hr = StringCchPrintfW(szKey, _countof(szKey), L"shell\\%s\\command", pszVerb);
619 return SUCCEEDED(hr) ? RunRegCommand(hWnd, hKey, szKey) : hr;
620}
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:597
#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 597 of file utils.cpp.

598{
599 WCHAR szCmd[MAX_PATH * 2];
600 DWORD cb = sizeof(szCmd);
602 if (error)
605}
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:573
#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 896 of file utils.cpp.

902{
903 SHDIALOG data = { fn, pThis };
904 return DialogBoxParamA(hInstance, lpTemplateName, hWndParent, SHDialogProc, (LPARAM)&data);
905}
HINSTANCE hInstance
Definition: charmap.c:19
static INT_PTR CALLBACK SHDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: utils.cpp:842
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 842 of file utils.cpp.

843{
846 HWND hwndItem;
847 LRESULT ret;
848
849 if (uMsg == WM_INITDIALOG)
850 {
853 lParam = (LPARAM)pData->pThis;
854 }
855 else
856 {
858 }
859
860 if (pData && pData->fn)
861 {
862 result = pData->fn(pData->pThis, hWnd, uMsg, wParam, lParam);
863 if (result)
864 return result;
865 }
866
867 switch (uMsg)
868 {
869 case WM_INITDIALOG:
870 return TRUE;
871
872 case WM_COMMAND:
873 if (LOWORD(wParam) == IDHELP)
874 return FALSE;
875
876 hwndItem = GetDlgItem(hWnd, LOWORD(wParam));
877 if (!hwndItem)
878 return FALSE;
879
880 ret = SendMessageA(hwndItem, WM_GETDLGCODE, 0, 0);
882 return FALSE;
883
885 return TRUE;
886
887 default:
888 return FALSE;
889 }
890}
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 573 of file utils.cpp.

574{
575 WCHAR szCmd[MAX_PATH * 2];
577 if (len <= 0) // Could not resolve the command, just use the input
578 {
579 HRESULT hr = StringCchCopyW(szCmd, _countof(szCmd), Command);
580 if (FAILED(hr))
581 return hr;
582 }
583 PWSTR pszArgs = PathGetArgsW(szCmd);
584 PathRemoveArgsW(szCmd);
585 PathUnquoteSpacesW(szCmd);
586
587 SHELLEXECUTEINFOW sei = { sizeof(sei), Flags, hWnd, NULL, szCmd, pszArgs };
588 sei.nShow = SW_SHOW;
591}
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:153
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 1199 of file utils.cpp.

1205{
1206 WCHAR szPathW[MAX_PATH], szVerKeyW[MAX_PATH], szDisplayNameW[MAX_PATH], szOutW[MAX_PATH];
1207 CHAR szOutA[MAX_PATH];
1208 BOOL ret;
1209 UINT cchOutW;
1210
1211 SHAnsiToUnicode(pszPath, szPathW, _countof(szPathW));
1212 szPathW[_countof(szPathW) - 1] = UNICODE_NULL;
1213
1214 if (pszVerKey)
1215 {
1216 SHAnsiToUnicode(pszVerKey, szVerKeyW, _countof(szVerKeyW));
1217 szVerKeyW[_countof(szVerKeyW) - 1] = UNICODE_NULL;
1218 }
1219
1220 if (pszDisplayName)
1221 {
1222 SHAnsiToUnicode(pszDisplayName, szDisplayNameW, _countof(szDisplayNameW));
1223 szDisplayNameW[_countof(szDisplayNameW) - 1] = UNICODE_NULL;
1224 }
1225
1226 cchOutW = (UINT)_countof(szOutW);
1227 ret = SHGetFileDescriptionW(szPathW, (pszVerKey ? szVerKeyW : NULL),
1228 (pszDisplayName ? szDisplayNameW : NULL), szOutW, &cchOutW);
1229 if (ret)
1230 {
1231 szOutW[_countof(szOutW) - 1] = UNICODE_NULL;
1232
1233 if (!pszOut)
1234 pszOut = szOutA;
1235
1236 SHUnicodeToAnsi(szOutW, pszOut, *pcchOut);
1237 if (*pcchOut > 0)
1238 pszOut[*pcchOut - 1] = ANSI_NULL;
1239 *pcchOut = lstrlenA(pszOut) + 1;
1240 }
1241
1242 return ret;
1243}
DWORD WINAPI SHAnsiToUnicode(const char *src, WCHAR *dest, int dest_len)
Definition: main.c:1801
DWORD WINAPI SHUnicodeToAnsi(const WCHAR *src, char *dest, int dest_len)
Definition: main.c:1756
BOOL WINAPI SHGetFileDescriptionW(_In_ PCWSTR pszPath, _In_opt_ PCWSTR pszVerKey, _In_opt_ PCWSTR pszDisplayName, _Out_opt_ PWSTR pszOut, _Inout_ PUINT pcchOut)
Definition: utils.cpp:1087
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 1087 of file utils.cpp.

1093{
1094 DWORD pdwAttrs = 0;
1095 if (!PathFileExistsAndAttributesW(pszPath, &pdwAttrs))
1096 return FALSE;
1097
1100
1101 PVOID pvDescription = NULL;
1102 UINT cchDescription = 0;
1103 PVOID pvBlock = NULL;
1104
1105 BOOL bIsFile = !(pdwAttrs & FILE_ATTRIBUTE_DIRECTORY) &&
1106 !PathIsUNCServerW(pszPath) &&
1107 !PathIsUNCServerShareW(pszPath);
1108 if (bIsFile)
1109 {
1110 DWORD dwHandle = 0;
1111 DWORD cbBlock = GetFileVersionInfoSizeW(szPath, &dwHandle);
1112 if (cbBlock)
1113 {
1114 pvBlock = LocalAlloc(LPTR, cbBlock);
1115 if (pvBlock && GetFileVersionInfoW(szPath, dwHandle, cbBlock, pvBlock))
1116 {
1117 WCHAR szSubBlock[60];
1118 BOOL ret = FALSE;
1119 if (pszVerKey)
1120 {
1121 StringCchCopyW(szSubBlock, _countof(szSubBlock), pszVerKey);
1122 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1123 }
1124
1125 if (!ret)
1126 {
1127 PVOID pTranslation = NULL;
1128 UINT cbTranslation = 0;
1129 if (VerQueryValueW(pvBlock, L"\\VarFileInfo\\Translation", &pTranslation,
1130 &cbTranslation) && cbTranslation)
1131 {
1132 UINT langId = ((PWORD)pTranslation)[0];
1133 UINT codePage = ((PWORD)pTranslation)[1];
1134 StringCchPrintfW(szSubBlock, _countof(szSubBlock),
1135 L"\\StringFileInfo\\%04X%04X\\FileDescription",
1136 langId, codePage);
1137 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1138 }
1139 }
1140
1141 if (!ret)
1142 {
1143 // 0x0409: English (United States), 0x04B0: UTF-16 codepage
1144 StringCchCopyW(szSubBlock, _countof(szSubBlock),
1145 L"\\StringFileInfo\\040904B0\\FileDescription");
1146 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1147 }
1148 if (!ret)
1149 {
1150 // 0x0409: English (United States), 0x04E4: Latin 1 codepage
1151 StringCchCopyW(szSubBlock, _countof(szSubBlock),
1152 L"\\StringFileInfo\\040904E4\\FileDescription");
1153 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1154 }
1155 if (!ret)
1156 {
1157 // 0x0409: English (United States), 0x0000: Neutral
1158 StringCchCopyW(szSubBlock, _countof(szSubBlock),
1159 L"\\StringFileInfo\\04090000\\FileDescription");
1160 ret = VerQueryValueW(pvBlock, szSubBlock, &pvDescription, &cchDescription);
1161 }
1162 }
1163 }
1164 }
1165
1166 PWSTR pszDescription = (PWSTR)pvDescription;
1167 if (!pszDescription || !*pszDescription)
1168 {
1170 pszDescription = PathFindFileNameW(szPath);
1171 cchDescription = lstrlenW(pszDescription);
1172 }
1173
1174 PrettifyFileDescriptionW(pszDescription, pszDisplayName);
1175
1176 UINT cchResult = lstrlenW(pszDescription) + 1;
1177 if (pszOut)
1178 {
1179 UINT cchCopy = min(cchResult, *pcchOut);
1180 StringCchCopyW(pszOut, cchCopy, pszDescription);
1181 *pcchOut = cchCopy;
1182 }
1183 else
1184 {
1185 *pcchOut = cchResult;
1186 }
1187
1188 if (pvBlock)
1189 LocalFree(pvBlock);
1190
1191 return TRUE;
1192}
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:1044
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 410 of file utils.cpp.

416{
417 return SHInvokeCommandOnContextMenuEx(hWnd, pUnk, pCM, fCMIC, CMF_EXTENDEDVERBS, pszVerb, NULL);
418}
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:393
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 393 of file utils.cpp.

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

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

314{
315 CMINVOKECOMMANDINFOEX info = { sizeof(info), fCMIC, hWnd, pszVerb };
316 INT iDefItem = 0;
317 HMENU hMenu = NULL;
318 HCURSOR hOldCursor;
319 HRESULT hr = S_OK;
320 WCHAR wideverb[MAX_PATH];
321
322 if (!pCM)
323 return E_INVALIDARG;
324
325 hOldCursor = SetCursor(LoadCursorW(NULL, (LPCWSTR)IDC_WAIT));
326 info.nShow = SW_NORMAL;
327 if (pUnk)
329
330 if (IS_INTRESOURCE(pszVerb))
331 {
332 hMenu = CreatePopupMenu();
333 if (hMenu)
334 {
335 hr = pCM->QueryContextMenu(hMenu, 0, 1, MAXSHORT, fCMF | CMF_DEFAULTONLY);
336 iDefItem = GetMenuDefaultItem(hMenu, 0, 0);
337 if (iDefItem != -1)
338 info.lpVerb = MAKEINTRESOURCEA(iDefItem - 1);
339 }
340 info.lpVerbW = MAKEINTRESOURCEW(info.lpVerb);
341 }
342 else
343 {
345 {
346 info.fMask |= CMF_OPTIMIZEFORINVOKE;
347 }
348 if (pszVerb && SHAnsiToUnicode(pszVerb, wideverb, _countof(wideverb)))
349 {
350 info.fMask |= CMIC_MASK_UNICODE;
351 info.lpVerbW = wideverb;
352 }
353 if (ForceQCM)
354 {
355 hMenu = CreatePopupMenu();
356 hr = pCM->QueryContextMenu(hMenu, 0, 1, MAXSHORT, fCMF);
357 }
358 }
359
360 SetCursor(hOldCursor);
361
362 if (!FAILED_UNEXPECTEDLY(hr) && (iDefItem != -1 || info.lpVerb))
363 {
364 if (!hWnd)
365 info.fMask |= CMIC_MASK_FLAG_NO_UI;
366
368 if (pwszDir)
369 {
370 info.fMask |= CMIC_MASK_UNICODE;
371 info.lpDirectoryW = pwszDir;
372 if (SHUnicodeToAnsi(pwszDir, dir, _countof(dir)))
373 info.lpDirectory = dir;
374 }
375
376 hr = pCM->InvokeCommand((LPCMINVOKECOMMANDINFO)&info);
377 if (FAILED_UNEXPECTEDLY(hr)) { /* Diagnostic message */ }
378 }
379
380 if (pUnk)
382 if (hMenu)
383 DestroyMenu(hMenu);
384
385 return hr;
386}
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: main.c:222
static WORD GetVersionMajorMinor()
Definition: utils.cpp:41
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 436 of file utils.cpp.

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

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

◆ SHLWAPI_IsBogusHRESULT()

static BOOL SHLWAPI_IsBogusHRESULT ( HRESULT  hr)
inlinestatic

Definition at line 691 of file utils.cpp.

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

Referenced by IShellFolder_GetDisplayNameOf().

◆ SHRestrictedMessageBox()

EXTERN_C INT WINAPI SHRestrictedMessageBox ( _In_ HWND  hWnd)

Definition at line 1251 of file utils.cpp.

1252{
1254 MAKEINTRESOURCEW(IDS_RESTRICTIONS), MB_ICONERROR);
1255}
#define ShellMessageBoxW
Definition: precomp.h:63
HINSTANCE shlwapi_hInstance
Definition: shlwapi_main.c:33
#define MB_ICONERROR
Definition: winuser.h:798

Referenced by ShowFolderOptionsDialogThreadProc().

◆ SHRunIndirectRegClientCommand()

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

Definition at line 626 of file utils.cpp.

627{
628 WCHAR szKey[MAX_PATH], szClient[MAX_PATH];
629 HRESULT hr = StringCchPrintfW(szKey, _countof(szKey), L"Software\\Clients\\%s", pszClientType);
630 if (FAILED(hr))
631 return hr;
632
633 // Find the default client
634 DWORD error, cb;
635 cb = sizeof(szClient);
637 if (error)
638 {
639 cb = sizeof(szClient);
642 if (error)
644 }
645
646 hr = StringCchPrintfW(szKey, _countof(szKey), L"Software\\Clients\\%s\\%s", pszClientType, szClient);
647 if (SUCCEEDED(hr))
649 return hr;
650}
EXTERN_C HRESULT WINAPI RunIndirectRegCommand(_In_opt_ HWND hWnd, _In_ HKEY hKey, _In_opt_ PCWSTR pszSubKey, _In_ PCWSTR pszVerb)
Definition: utils.cpp:611
#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 48 of file utils.cpp.

54{
55 CHAR szBuff[MAX_PATH];
56 INT cchExpanded;
57
58 if (hUserToken)
59 {
60 if (ExpandEnvironmentStringsForUserA(hUserToken, lpSrc, szBuff, _countof(szBuff)))
61 cchExpanded = lstrlenA(szBuff) + 1;
62 else
63 cchExpanded = 0;
64 }
65 else
66 {
67 cchExpanded = ExpandEnvironmentStringsA(lpSrc, szBuff, _countof(szBuff));
68 }
69
70 if (!cchExpanded || cchExpanded > cchDest)
71 return FALSE;
72
73 INT cchEnvPath = cchExpanded - 1;
75 szBuff, cchEnvPath, lpString, cchEnvPath) != CSTR_EQUAL)
76 {
77 return FALSE;
78 }
79
80 INT cchSuffix = lstrlenA(lpString) - cchEnvPath;
81 if (lstrlenA(lpSrc) + cchSuffix >= cchDest)
82 return FALSE;
83
84 StringCchCopyA(pszDest, cchDest, lpSrc);
85 StringCchCatA(pszDest, cchDest, &lpString[cchEnvPath]);
86 return TRUE;
87}
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 90 of file utils.cpp.

96{
97 WCHAR szBuff[MAX_PATH];
98 INT cchExpanded;
99
100 if (hUserToken)
101 {
102 if (ExpandEnvironmentStringsForUserW(hUserToken, lpSrc, szBuff, _countof(szBuff)))
103 cchExpanded = lstrlenW(szBuff) + 1;
104 else
105 cchExpanded = 0;
106 }
107 else
108 {
109 cchExpanded = ExpandEnvironmentStringsW(lpSrc, szBuff, _countof(szBuff));
110 }
111
112 if (!cchExpanded || cchExpanded > cchDest)
113 return FALSE;
114
115 INT cchEnvPath = cchExpanded - 1;
117 szBuff, cchEnvPath, lpString, cchEnvPath) != CSTR_EQUAL)
118 {
119 return FALSE;
120 }
121
122 INT cchSuffix = lstrlenW(lpString) - cchEnvPath;
123 if (lstrlenW(lpSrc) + cchSuffix >= cchDest)
124 return FALSE;
125
126 StringCchCopyW(pszDest, cchDest, lpSrc);
127 StringCchCatW(pszDest, cchDest, &lpString[cchEnvPath]);
128 return TRUE;
129}
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 703 of file utils.cpp.

Referenced by IShellFolder_GetDisplayNameOf().