mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:22:57 +00:00
[SHELLUTILS]
- Add a helper function SHSetStrRet that will simplify setting the contents of a STRRET. svn path=/trunk/; revision=68844
This commit is contained in:
parent
e950972731
commit
73a3fd8b3c
1 changed files with 31 additions and 0 deletions
|
@ -485,6 +485,37 @@ HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4
|
||||||
|
|
||||||
return S_OK;
|
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 /* __cplusplus */
|
||||||
|
|
||||||
#endif /* __ROS_SHELL_UTILS_H */
|
#endif /* __ROS_SHELL_UTILS_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue