ReactOS 0.4.16-dev-853-g88d9285
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class H >
static int ErrorBox (H hWnd, int Error)
 
template<class T >
static bool IsPathSep (T c)
 
bool IsEqual (const SHCOLUMNID &scid, REFGUID guid, UINT pid)
 
HRESULT InitVariantFromBuffer (const void *buffer, UINT cb, VARIANT *pv)
 
void FreeStrRet (STRRET &str)
 
HRESULT StrTo (LPCWSTR str, UINT len, STRRET &sr)
 
HRESULT StrTo (LPCWSTR str, STRRET &sr)
 
HRESULT StrTo (LPCWSTR str, UINT len, VARIANT &v)
 
HRESULT StrTo (LPCWSTR str, VARIANT &v)
 
HRESULT StrRetToVariantBSTR (STRRET *psr, VARIANT &v)
 
HRESULT GetDetailsOf (IShellFolder2 &Folder, PCUITEMID_CHILD pidl, UINT Column, PWSTR &String)
 
HRESULT InsertMenuItem (QCMINFO &qcmi, UINT &Pos, UINT &TrackId, UINT Id, UINT ResId, int State=0)
 
SFGAOF MapFSToSFAttributes (UINT att)
 
bool IncludeInEnumIDList (SHCONTF contf, SFGAOF att)
 
int MapPIDLToSystemImageListIndex (IShellFolder *pSF, PCUITEMID_CHILD pidl, UINT GilFlags=0)
 

Function Documentation

◆ ErrorBox()

template<class H >
static int ErrorBox ( H  hWnd,
int  Error 
)
static

Definition at line 10 of file util.h.

11{
13 return Error;
14}
HWND hWnd
Definition: settings.c:17
BOOL Error
Definition: chkdsk.c:66
#define SHELL_ErrorBox
Definition: shellutils.h:126

◆ FreeStrRet()

void FreeStrRet ( STRRET str)
inline

Definition at line 40 of file util.h.

41{
42 if (str.uType == STRRET_WSTR)
43 {
44 SHFree(str.pOleStr);
45 str.uType = STRRET_CSTR;
46 }
47}
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
const WCHAR * str
@ STRRET_CSTR
Definition: shtypes.idl:87
@ STRRET_WSTR
Definition: shtypes.idl:85

◆ GetDetailsOf()

HRESULT GetDetailsOf ( IShellFolder2 Folder,
PCUITEMID_CHILD  pidl,
UINT  Column,
PWSTR String 
)
inline

Definition at line 88 of file util.h.

89{
91 HRESULT hr = Folder.GetDetailsOf(pidl, Column, &details);
92 if (SUCCEEDED(hr))
93 hr = StrRetToStrW(&details.str, pidl, &String);
94 return hr;
95}
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1631
HRESULT GetDetailsOf([in] PCUITEMID_CHILD pidl, [in] UINT iColumn, [out] SHELLDETAILS *psd)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
int details
Definition: msacm.c:1366
HRESULT hr
Definition: shlfolder.c:183
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by DECLARE_INTERFACE_().

◆ IncludeInEnumIDList()

bool IncludeInEnumIDList ( SHCONTF  contf,
SFGAOF  att 
)
inline

Definition at line 131 of file util.h.

132{
133 const SHCONTF both = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS;
134 const SFGAOF superbits = SFGAO_HIDDEN | SFGAO_READONLY | SFGAO_SYSTEM;
135 const bool isfile = (att & (SFGAO_STREAM | SFGAO_FOLDER)) != SFGAO_FOLDER;
136 if ((contf & both) != both && !(contf & SHCONTF_STORAGE))
137 {
138 if (isfile && (contf & SHCONTF_FOLDERS))
139 return false;
140 if ((att & SFGAO_FOLDER) && (contf & SHCONTF_NONFOLDERS))
141 return false;
142 }
143 if ((att & SFGAO_HIDDEN) && !(contf & (SHCONTF_INCLUDEHIDDEN | SHCONTF_STORAGE)))
144 return false;
145 if ((att & superbits) > SFGAO_HIDDEN && !(contf & (SHCONTF_INCLUDESUPERHIDDEN | SHCONTF_STORAGE)))
146 return false;
147 return true;
148}
#define SFGAO_SYSTEM
Definition: shobjidl.idl:198
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
static SHCONTF
Definition: ordinal.c:64

Referenced by EnumFillCallback().

◆ InitVariantFromBuffer()

HRESULT InitVariantFromBuffer ( const void buffer,
UINT  cb,
VARIANT pv 
)
inline

Definition at line 26 of file util.h.

27{
29 if (pa)
30 {
31 CopyMemory(pa->pvData, buffer, cb);
32 V_VT(pv) = VT_UI1 | VT_ARRAY;
33 V_UNION(pv, parray) = pa;
34 return S_OK;
35 }
36 V_VT(pv) = VT_EMPTY;
37 return E_OUTOFMEMORY;
38}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
@ VT_ARRAY
Definition: compat.h:2341
@ VT_EMPTY
Definition: compat.h:2295
@ VT_UI1
Definition: compat.h:2311
SAFEARRAY *WINAPI SafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements)
Definition: safearray.c:677
GLuint buffer
Definition: glext.h:5915
#define S_OK
Definition: intsafe.h:52
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static int ** pa
Definition: server.c:126
#define V_VT(A)
Definition: oleauto.h:211
#define V_UNION(A, B)
Definition: oleauto.h:212
#define CopyMemory
Definition: winbase.h:1735

Referenced by CCabFolder::GetDetailsEx(), and test_InitPropVariantFromBuffer().

◆ InsertMenuItem()

HRESULT InsertMenuItem ( QCMINFO qcmi,
UINT Pos,
UINT TrackId,
UINT  Id,
UINT  ResId,
int  State = 0 
)
inline

Definition at line 97 of file util.h.

98{
99 UINT flags = 0;
100 WCHAR string[MAX_PATH];
101 string[0] = UNICODE_NULL;
102 if ((Id += qcmi.idCmdFirst) > qcmi.idCmdLast)
103 return E_FAIL;
104 else if (ResId == (UINT)-1)
106 else if (!LoadStringW(_AtlBaseModule.GetResourceInstance(), ResId, string, _countof(string)))
107 return E_FAIL;
108
109 MENUITEMINFOW mii;
110 mii.cbSize = FIELD_OFFSET(MENUITEMINFOW, hbmpItem); // USER32 version agnostic
112 mii.fType = flags;
113 mii.wID = Id;
114 mii.dwTypeData = string;
115 mii.cch = 0;
116 mii.fState = State;
117 if (!InsertMenuItemW(qcmi.hmenu, Pos, TRUE, &mii))
118 return E_FAIL;
119 Pos++;
120 TrackId = max(TrackId, Id);
121 return S_OK;
122}
DWORD Id
#define E_FAIL
Definition: ddrawi.h:102
ush Pos
Definition: deflate.h:92
#define TRUE
Definition: types.h:120
#define MAX_PATH
Definition: compat.h:34
GLbitfield flags
Definition: glext.h:7161
char string[160]
Definition: util.h:11
unsigned int UINT
Definition: ndis.h:50
#define UNICODE_NULL
#define _countof(array)
Definition: sndvol32.h:70
HMENU hmenu
Definition: shlobj.h:1398
UINT idCmdLast
Definition: shlobj.h:1401
UINT idCmdFirst
Definition: shlobj.h:1400
LPWSTR dwTypeData
Definition: winuser.h:3272
#define max(a, b)
Definition: svc.c:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define MIIM_STRING
Definition: winuser.h:730
#define MIIM_ID
Definition: winuser.h:725
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MIIM_FTYPE
Definition: winuser.h:732
#define MIIM_STATE
Definition: winuser.h:724
#define MF_SEPARATOR
Definition: winuser.h:137
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ IsEqual()

bool IsEqual ( const SHCOLUMNID &  scid,
REFGUID  guid,
UINT  pid 
)
inline

Definition at line 21 of file util.h.

22{
23 return scid.pid == pid && IsEqualGUID(scid.fmtid, guid);
24}
const GUID * guid
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

◆ IsPathSep()

template<class T >
static bool IsPathSep ( T  c)
inlinestatic

Definition at line 16 of file util.h.

17{
18 return c == '\\' || c == '/';
19}
const GLubyte * c
Definition: glext.h:8905

Referenced by BuildPath().

◆ MapFSToSFAttributes()

SFGAOF MapFSToSFAttributes ( UINT  att)
inline

Definition at line 124 of file util.h.

125{
126 return ((att & FILE_ATTRIBUTE_READONLY) ? SFGAO_READONLY : 0) |
127 ((att & FILE_ATTRIBUTE_HIDDEN) ? SFGAO_HIDDEN : 0) |
128 ((att & FILE_ATTRIBUTE_SYSTEM) ? SFGAO_SYSTEM : 0);
129}
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704

Referenced by EnumFillCallback(), and CCabFolder::GetAttributesOf().

◆ MapPIDLToSystemImageListIndex()

int MapPIDLToSystemImageListIndex ( IShellFolder pSF,
PCUITEMID_CHILD  pidl,
UINT  GilFlags = 0 
)
inline

Definition at line 150 of file util.h.

151{
152 int normal, open;
153 BOOL qopen = GilFlags & GIL_OPENICON;
154 normal = SHMapPIDLToSystemImageListIndex(pSF, pidl, qopen ? &open : NULL);
155 return qopen && open != -1 ? open : normal;
156}
#define open
Definition: acwin.h:95
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder *sh, LPCITEMIDLIST pidl, int *pIndex)
Definition: iconcache.cpp:772
@ normal
Definition: optimize.h:166

Referenced by CCabFolder::GetIconOf().

◆ StrRetToVariantBSTR()

HRESULT StrRetToVariantBSTR ( STRRET psr,
VARIANT v 
)
inline

Definition at line 80 of file util.h.

81{
82 HRESULT hr = StrRetToBSTR(psr, NULL, &V_BSTR(&v));
83 if (SUCCEEDED(hr))
84 V_VT(&v) = VT_BSTR;
85 return hr;
86}
@ VT_BSTR
Definition: compat.h:2303
HRESULT WINAPI StrRetToBSTR(STRRET *lpStrRet, LPCITEMIDLIST pidl, BSTR *pBstrOut)
Definition: string.c:1700
const GLdouble * v
Definition: gl.h:2040
#define V_BSTR(A)
Definition: oleauto.h:226

Referenced by CCabFolder::GetItemDetails().

◆ StrTo() [1/4]

HRESULT StrTo ( LPCWSTR  str,
STRRET sr 
)
inline

Definition at line 60 of file util.h.

61{
62 return StrTo(str, lstrlenW(str), sr);
63}
HRESULT StrTo(LPCWSTR str, UINT len, STRRET &sr)
Definition: util.h:49
#define lstrlenW
Definition: compat.h:750

◆ StrTo() [2/4]

HRESULT StrTo ( LPCWSTR  str,
UINT  len,
STRRET sr 
)
inline

Definition at line 49 of file util.h.

50{
51 LPWSTR data = (LPWSTR)SHAlloc(++len * sizeof(WCHAR));
52 if (!data)
53 return E_OUTOFMEMORY;
55 sr.uType = STRRET_WSTR;
56 sr.pOleStr = data;
57 return S_OK;
58}
#define lstrcpynW
Definition: compat.h:738
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
UINT uType
Definition: shtypes.idl:93
LPWSTR pOleStr
Definition: shtypes.idl:96
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CCabFolder::GetDetailsOf(), CCabFolder::GetDisplayNameOf(), CCabFolder::GetItemDetails(), and StrTo().

◆ StrTo() [3/4]

HRESULT StrTo ( LPCWSTR  str,
UINT  len,
VARIANT v 
)
inline

Definition at line 65 of file util.h.

66{
68 if (!data)
69 return E_OUTOFMEMORY;
70 V_VT(&v) = VT_BSTR;
71 V_BSTR(&v) = data;
72 return S_OK;
73}
OLECHAR * BSTR
Definition: compat.h:2293
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339

◆ StrTo() [4/4]

HRESULT StrTo ( LPCWSTR  str,
VARIANT v 
)
inline

Definition at line 75 of file util.h.

76{
77 return StrTo(str, lstrlenW(str), v);
78}