ReactOS 0.4.16-dev-1044-ga6558c0
utils.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CMVERBMAP
 

Macros

#define OPTIONAL_(arg)
 

Functions

static BOOL IsEqualPersistClassID (IPersist *pPersist, REFCLSID clsid)
 
static BOOL RegValueExists (HKEY hKey, LPCWSTR Name)
 
BOOL RegKeyExists (HKEY hKey, LPCWSTR Path)
 
DWORD RegSetOrDelete (HKEY hKey, LPCWSTR Name, DWORD Type, LPCVOID Data, DWORD Size)
 
static DWORD RegSetString (HKEY hKey, LPCWSTR Name, LPCWSTR Str, DWORD Type OPTIONAL_(REG_SZ))
 
HRESULT SHELL_MapContextMenuVerbToCmdId (LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
 
HRESULT SHELL_GetCommandStringImpl (SIZE_T CmdId, UINT uFlags, LPSTR Buf, UINT cchBuf, const CMVERBMAP *pMap)
 
HICON SHELL32_SHExtractIcon (LPCWSTR File, int Index, int cx, int cy)
 
HRESULT SHELL_CreateShell32DefaultExtractIcon (int IconIndex, REFIID riid, LPVOID *ppvOut)
 
static HRESULT SHELL_CreateFallbackExtractIconForFolder (REFIID riid, LPVOID *ppvOut)
 
static HRESULT SHELL_CreateFallbackExtractIconForNoAssocFile (REFIID riid, LPVOID *ppvOut)
 

Macro Definition Documentation

◆ OPTIONAL_

#define OPTIONAL_ (   arg)

Definition at line 14 of file utils.h.

Function Documentation

◆ IsEqualPersistClassID()

static BOOL IsEqualPersistClassID ( IPersist pPersist,
REFCLSID  clsid 
)
inlinestatic

Definition at line 36 of file utils.h.

37{
38 CLSID temp;
39 return pPersist && SUCCEEDED(pPersist->GetClassID(&temp)) && IsEqualCLSID(clsid, temp);
40}
HRESULT GetClassID([out] CLSID *pClassID)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
REFCLSID clsid
Definition: msctf.c:82
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by CDefView::OnCreate().

◆ RegKeyExists()

BOOL RegKeyExists ( HKEY  hKey,
LPCWSTR  Path 
)
inline

Definition at line 49 of file utils.h.

50{
52 if (ret)
54 return ret;
55}
PRTL_UNICODE_STRING_BUFFER Path
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
int ret

Referenced by EditTypeDlg_ReadClass(), and EditTypeDlg_WriteClass().

◆ RegSetOrDelete()

DWORD RegSetOrDelete ( HKEY  hKey,
LPCWSTR  Name,
DWORD  Type,
LPCVOID  Data,
DWORD  Size 
)
inline

Definition at line 58 of file utils.h.

59{
60 if (Data)
61 return RegSetValueExW(hKey, Name, 0, Type, (LPBYTE)Data, Size);
62 else
63 return RegDeleteValueW(hKey, Name);
64}
Type
Definition: Type.h:7
LPWSTR Name
Definition: desk.c:124
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by EditTypeDlg_WriteClass().

◆ RegSetString()

static DWORD RegSetString ( HKEY  hKey,
LPCWSTR  Name,
LPCWSTR  Str,
DWORD Type   OPTIONAL_REG_SZ 
)
inlinestatic

Definition at line 67 of file utils.h.

68{
69 return RegSetValueExW(hKey, Name, 0, Type, (LPBYTE)Str, (lstrlenW(Str) + 1) * sizeof(WCHAR));
70}
#define lstrlenW
Definition: compat.h:750
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by EditTypeDlg_WriteClass(), FileTypesDlg_AddExt(), and COpenWithList::SetDefaultHandler().

◆ RegValueExists()

static BOOL RegValueExists ( HKEY  hKey,
LPCWSTR  Name 
)
inlinestatic

Definition at line 43 of file utils.h.

44{
46}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
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

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu(), EditTypeDlg_ReadClass(), and FileTypesDlg_InsertToLV().

◆ SHELL32_SHExtractIcon()

HICON SHELL32_SHExtractIcon ( LPCWSTR  File,
int  Index,
int  cx,
int  cy 
)
inline

Definition at line 85 of file utils.h.

86{
87 HICON hIco;
88 int r = PrivateExtractIconsW(File, Index, cx, cy, &hIco, NULL, 1, 0);
89 return r > 0 ? hIco : NULL;
90}
Definition: File.h:16
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HICON
Definition: imagelist.c:80
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
_In_ WDFCOLLECTION _In_ ULONG Index
UINT WINAPI PrivateExtractIconsW(_In_reads_(MAX_PATH) LPCWSTR szFileName, _In_ int nIconIndex, _In_ int cxIcon, _In_ int cyIcon, _Out_writes_opt_(nIcons) HICON *phicon, _Out_writes_opt_(nIcons) UINT *piconid, _In_ UINT nIcons, _In_ UINT flags)

Referenced by DoExtractIcon().

◆ SHELL_CreateFallbackExtractIconForFolder()

static HRESULT SHELL_CreateFallbackExtractIconForFolder ( REFIID  riid,
LPVOID ppvOut 
)
inlinestatic

Definition at line 96 of file utils.h.

97{
98 const int id = IDI_SHELL_FOLDER;
99 return SHELL_CreateShell32DefaultExtractIcon(id > 1 ? -id : 0, riid, ppvOut);
100}
#define IDI_SHELL_FOLDER
Definition: treeview.c:21
HRESULT SHELL_CreateShell32DefaultExtractIcon(int IconIndex, REFIID riid, LPVOID *ppvOut)
Definition: utils.cpp:1806
REFIID riid
Definition: atlbase.h:39

Referenced by CRecyclerExtractIcon_CreateInstance().

◆ SHELL_CreateFallbackExtractIconForNoAssocFile()

static HRESULT SHELL_CreateFallbackExtractIconForNoAssocFile ( REFIID  riid,
LPVOID ppvOut 
)
inlinestatic

Definition at line 103 of file utils.h.

104{
105 const int id = IDI_SHELL_DOCUMENT;
106 return SHELL_CreateShell32DefaultExtractIcon(id > 1 ? -id : 0, riid, ppvOut);
107}
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:579

Referenced by CRecyclerExtractIcon_CreateInstance().

◆ SHELL_CreateShell32DefaultExtractIcon()

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

Definition at line 1806 of file utils.cpp.

1807{
1811 return hr;
1812 initIcon->SetNormalIcon(swShell32Name, IconIndex);
1813 return initIcon->QueryInterface(riid, ppvOut);
1814}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define FAILED_UNEXPECTEDLY(hr)
Definition: debug.h:83
static const WCHAR IconIndex[]
Definition: install.c:52
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)

Referenced by SHELL_CreateFallbackExtractIconForFolder(), and SHELL_CreateFallbackExtractIconForNoAssocFile().

◆ SHELL_GetCommandStringImpl()

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

Definition at line 1783 of file utils.cpp.

1784{
1785 const CMVERBMAP* pEntry;
1786 switch (uFlags | GCS_UNICODE)
1787 {
1788 case GCS_VALIDATEW:
1789 case GCS_VERBW:
1790 pEntry = FindVerbMapEntry(CmdId, pMap);
1791 if ((uFlags | GCS_UNICODE) == GCS_VERBW)
1792 {
1793 if (!pEntry)
1794 return E_INVALIDARG;
1795 else if (uFlags & GCS_UNICODE)
1796 return SHAnsiToUnicode(pEntry->Verb, (LPWSTR)Buf, cchBuf) ? S_OK : E_FAIL;
1797 else
1798 return StringCchCopyA(Buf, cchBuf, pEntry->Verb);
1799 }
1800 return pEntry ? S_OK : S_FALSE; // GCS_VALIDATE
1801 }
1802 return E_NOTIMPL;
1803}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
UINT uFlags
Definition: api.c:59
static const CMVERBMAP * FindVerbMapEntry(UINT_PTR CmdId, const CMVERBMAP *pMap)
Definition: utils.cpp:1772
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define S_OK
Definition: intsafe.h:52
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
#define S_FALSE
Definition: winerror.h:2357
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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

◆ SHELL_MapContextMenuVerbToCmdId()

HRESULT SHELL_MapContextMenuVerbToCmdId ( LPCMINVOKECOMMANDINFO  pICI,
const CMVERBMAP pMap 
)

Definition at line 1749 of file utils.cpp.

1750{
1751 LPCSTR pVerbA = pICI->lpVerb;
1752 CHAR buf[MAX_PATH];
1753 LPCMINVOKECOMMANDINFOEX pICIX = (LPCMINVOKECOMMANDINFOEX)pICI;
1754 if (IsUnicode(*pICIX) && !IS_INTRESOURCE(pICIX->lpVerbW))
1755 {
1756 if (SHUnicodeToAnsi(pICIX->lpVerbW, buf, _countof(buf)))
1757 pVerbA = buf;
1758 }
1759
1760 if (IS_INTRESOURCE(pVerbA))
1761 return LOWORD(pVerbA);
1762 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1763 {
1764 assert(SUCCEEDED((int)(pMap[i].CmdId))); // The id must be >= 0 and ideally in the 0..0x7fff range
1765 if (!lstrcmpiA(pMap[i].Verb, pVerbA) && pVerbA[0])
1766 return pMap[i].CmdId;
1767 }
1768 return E_FAIL;
1769}
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4224
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2797
#define assert(x)
Definition: debug.h:53
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LOWORD(l)
Definition: pedump.c:82
#define _countof(array)
Definition: sndvol32.h:70
WORD CmdId
Definition: utils.h:75
LPCSTR Verb
Definition: utils.h:74
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
const char * LPCSTR
Definition: xmlstorage.h:183
char CHAR
Definition: xmlstorage.h:175

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