ReactOS 0.4.17-dev-116-ga4b6fe9
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)
 
#define DCIA_Create()   ( (HDCIA)DSA_Create(sizeof(CLSID), 4) )
 
#define DCIA_Destroy(hDCIA)   DSA_Destroy((HDSA)(hDCIA))
 
#define DCIA_GetCount(hDCIA)   DSA_GetItemCount((HDSA)(hDCIA))
 
#define DCIA_GetEntry(hDCIA, iItem)   ( (const CLSID*)DSA_GetItemPtr((HDSA)(hDCIA), (iItem)) )
 

Typedefs

typedef HDSA HDCIA
 

Functions

static BOOL IsEqualPersistClassID (IPersist *pPersist, REFCLSID clsid)
 
static BOOL RegValueExists (HKEY hKey, LPCWSTR Name)
 
BOOL RegKeyExists (HKEY hKey, LPCWSTR Path)
 
UINT RegQueryDword (HKEY hKey, PCWSTR pszPath, PCWSTR pszName, DWORD *pnVal)
 
DWORD RegGetDword (HKEY hKey, PCWSTR pszPath, PCWSTR pszName, DWORD nDefVal)
 
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)
 
int DCIA_AddEntry (HDCIA hDCIA, REFCLSID rClsId)
 
void DCIA_AddShellExSubkey (HDCIA hDCIA, HKEY hProgId, PCWSTR pszSubkey)
 

Macro Definition Documentation

◆ DCIA_Create

#define DCIA_Create ( )    ( (HDCIA)DSA_Create(sizeof(CLSID), 4) )

Definition at line 124 of file utils.h.

◆ DCIA_Destroy

#define DCIA_Destroy (   hDCIA)    DSA_Destroy((HDSA)(hDCIA))

Definition at line 125 of file utils.h.

◆ DCIA_GetCount

#define DCIA_GetCount (   hDCIA)    DSA_GetItemCount((HDSA)(hDCIA))

Definition at line 126 of file utils.h.

◆ DCIA_GetEntry

#define DCIA_GetEntry (   hDCIA,
  iItem 
)    ( (const CLSID*)DSA_GetItemPtr((HDSA)(hDCIA), (iItem)) )

Definition at line 127 of file utils.h.

◆ OPTIONAL_

#define OPTIONAL_ (   arg)

Definition at line 14 of file utils.h.

Typedef Documentation

◆ HDCIA

typedef HDSA HDCIA

Definition at line 123 of file utils.h.

Function Documentation

◆ DCIA_AddEntry()

int DCIA_AddEntry ( HDCIA  hDCIA,
REFCLSID  rClsId 
)

Definition at line 1907 of file utils.cpp.

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

Referenced by DCIA_AddShellExSubkey().

◆ DCIA_AddShellExSubkey()

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

Definition at line 1920 of file utils.cpp.

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

Referenced by CFSDropTarget::_GetEffectFromMenu().

◆ 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 IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by CDefView::OnCreate().

◆ RegGetDword()

DWORD RegGetDword ( HKEY  hKey,
PCWSTR  pszPath,
PCWSTR  pszName,
DWORD  nDefVal 
)
inline

Definition at line 65 of file utils.h.

66{
67 DWORD nVal;
68 return RegQueryDword(hKey, pszPath, pszName, &nVal) == ERROR_SUCCESS ? nVal : nDefVal;
69}
UINT RegQueryDword(HKEY hKey, PCWSTR pszPath, PCWSTR pszName, DWORD *pnVal)
Definition: utils.h:58
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu(), and CDefaultContextMenu::BrowserFlagsFromVerb().

◆ 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
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83

Referenced by DCMA_InsertMenuItems(), EditTypeDlg_ReadClass(), and EditTypeDlg_WriteClass().

◆ RegQueryDword()

UINT RegQueryDword ( HKEY  hKey,
PCWSTR  pszPath,
PCWSTR  pszName,
DWORD pnVal 
)
inline

Definition at line 58 of file utils.h.

59{
60 DWORD cb = sizeof(*pnVal);
61 return RegGetValueW(hKey, pszPath, pszName, RRF_RT_REG_DWORD, NULL, pnVal, &cb);
62}
#define NULL
Definition: types.h:112
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
#define RRF_RT_REG_DWORD
Definition: winreg.h:61

Referenced by RegGetDword().

◆ RegSetOrDelete()

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

Definition at line 72 of file utils.h.

73{
74 if (Data)
75 return RegSetValueExW(hKey, Name, 0, Type, (LPBYTE)Data, Size);
76 else
77 return RegDeleteValueW(hKey, Name);
78}
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:4539

Referenced by EditTypeDlg_WriteClass().

◆ RegSetString()

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

Definition at line 81 of file utils.h.

82{
83 return RegSetValueExW(hKey, Name, 0, Type, (LPBYTE)Str, (lstrlenW(Str) + 1) * sizeof(WCHAR));
84}
#define lstrlenW
Definition: compat.h:750

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}
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 99 of file utils.h.

100{
101 HICON hIco;
102 int r = PrivateExtractIconsW(File, Index, cx, cy, &hIco, NULL, 1, 0);
103 return r > 0 ? hIco : NULL;
104}
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 110 of file utils.h.

111{
112 const int id = IDI_SHELL_FOLDER;
113 return SHELL_CreateShell32DefaultExtractIcon(id > 1 ? -id : 0, riid, ppvOut);
114}
#define IDI_SHELL_FOLDER
Definition: treeview.c:21
HRESULT SHELL_CreateShell32DefaultExtractIcon(int IconIndex, REFIID riid, LPVOID *ppvOut)
Definition: utils.cpp:1897
REFIID riid
Definition: atlbase.h:39

Referenced by CRecyclerExtractIcon_CreateInstance().

◆ SHELL_CreateFallbackExtractIconForNoAssocFile()

static HRESULT SHELL_CreateFallbackExtractIconForNoAssocFile ( REFIID  riid,
LPVOID ppvOut 
)
inlinestatic

Definition at line 117 of file utils.h.

118{
119 const int id = IDI_SHELL_DOCUMENT;
120 return SHELL_CreateShell32DefaultExtractIcon(id > 1 ? -id : 0, riid, ppvOut);
121}
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:594

Referenced by CRecyclerExtractIcon_CreateInstance().

◆ SHELL_CreateShell32DefaultExtractIcon()

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

Definition at line 1897 of file utils.cpp.

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

1875{
1876 const CMVERBMAP* pEntry;
1877 switch (uFlags | GCS_UNICODE)
1878 {
1879 case GCS_VALIDATEW:
1880 case GCS_VERBW:
1881 pEntry = FindVerbMapEntry(CmdId, pMap);
1882 if ((uFlags | GCS_UNICODE) == GCS_VERBW)
1883 {
1884 if (!pEntry)
1885 return E_INVALIDARG;
1886 else if (uFlags & GCS_UNICODE)
1887 return SHAnsiToUnicode(pEntry->Verb, (LPWSTR)Buf, cchBuf) ? S_OK : E_FAIL;
1888 else
1889 return StringCchCopyA(Buf, cchBuf, pEntry->Verb);
1890 }
1891 return pEntry ? S_OK : S_FALSE; // GCS_VALIDATE
1892 }
1893 return E_NOTIMPL;
1894}
#define E_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:1863
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2803
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define S_OK
Definition: intsafe.h:52
_In_ UINT cchBuf
Definition: shlwapi.h:378
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
uint16_t * LPWSTR
Definition: typedefs.h:56
#define S_FALSE
Definition: winerror.h:3451

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

◆ SHELL_MapContextMenuVerbToCmdId()

HRESULT SHELL_MapContextMenuVerbToCmdId ( LPCMINVOKECOMMANDINFO  pICI,
const CMVERBMAP pMap 
)

Definition at line 1840 of file utils.cpp.

1841{
1842 LPCSTR pVerbA = pICI->lpVerb;
1843 CHAR buf[MAX_PATH];
1844 LPCMINVOKECOMMANDINFOEX pICIX = (LPCMINVOKECOMMANDINFOEX)pICI;
1845 if (IsUnicode(*pICIX) && !IS_INTRESOURCE(pICIX->lpVerbW))
1846 {
1847 if (SHUnicodeToAnsi(pICIX->lpVerbW, buf, _countof(buf)))
1848 pVerbA = buf;
1849 }
1850
1851 if (IS_INTRESOURCE(pVerbA))
1852 return LOWORD(pVerbA);
1853 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1854 {
1855 assert(SUCCEEDED((int)(pMap[i].CmdId))); // The id must be >= 0 and ideally in the 0..0x7fff range
1856 if (!lstrcmpiA(pMap[i].Verb, pVerbA) && pVerbA[0])
1857 return pMap[i].CmdId;
1858 }
1859 return E_FAIL;
1860}
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
#define IS_INTRESOURCE(x)
Definition: loader.c:613
#define assert(_expr)
Definition: assert.h:32
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2927
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define LOWORD(l)
Definition: pedump.c:82
char CHAR
Definition: pedump.c:57
WORD CmdId
Definition: utils.h:89
LPCSTR Verb
Definition: utils.h:88
const char * LPCSTR
Definition: typedefs.h:52
ULONG_PTR SIZE_T
Definition: typedefs.h:80

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