Author: gadamopoulos
Date: Fri Aug 28 10:32:02 2015
New Revision: 68844
URL:
http://svn.reactos.org/svn/reactos?rev=68844&view=rev
Log:
[SHELLUTILS]
- Add a helper function SHSetStrRet that will simplify setting the contents of a STRRET.
Modified:
trunk/reactos/include/reactos/shellutils.h
Modified: trunk/reactos/include/reactos/shellutils.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/shellutils…
==============================================================================
--- trunk/reactos/include/reactos/shellutils.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/shellutils.h [iso-8859-1] Fri Aug 28 10:32:02 2015
@@ -485,6 +485,37 @@
return S_OK;
}
+
+HRESULT inline SHSetStrRet(LPSTRRET pStrRet, LPCSTR pstrValue)
+{
+ pStrRet->uType = STRRET_CSTR;
+ strcpy(pStrRet->cStr, pstrValue);
+ return S_OK;
+}
+
+HRESULT inline SHSetStrRet(LPSTRRET pStrRet, LPCWSTR pwstrValue)
+{
+ ULONG cchr = wcslen(pwstrValue);
+ LPWSTR buffer = static_cast<LPWSTR>(CoTaskMemAlloc((cchr + 1) *
sizeof(WCHAR)));
+ if (buffer == NULL)
+ return E_OUTOFMEMORY;
+
+ pStrRet->uType = STRRET_WSTR;
+ pStrRet->pOleStr = buffer;
+ wcscpy(buffer, pwstrValue);
+ return S_OK;
+}
+
+HRESULT inline SHSetStrRet(LPSTRRET pStrRet, HINSTANCE hInstance, DWORD resId)
+{
+ WCHAR Buffer[MAX_PATH];
+
+ if (!LoadStringW(hInstance, resId, Buffer, MAX_PATH))
+ return E_FAIL;
+
+ return SHSetStrRet(pStrRet, Buffer);
+}
+
#endif /* __cplusplus */
#endif /* __ROS_SHELL_UTILS_H */