Implement StrRetToStr in shlwapi.

This commit is contained in:
Juergen Schmied 2002-08-06 23:50:27 +00:00 committed by Alexandre Julliard
parent afe785c4d5
commit 53e5bd5000
2 changed files with 119 additions and 2 deletions

View File

@ -686,8 +686,8 @@ init SHLWAPI_LibMain
# exported in later versions
@ stdcall StrRetToBufA (ptr ptr ptr long) StrRetToBufA
@ stdcall StrRetToBufW (ptr ptr ptr long) StrRetToBufW
#@ stdcall StrRetToStrA (ptr ptr ptr) StrRetToStrA
#@ stdcall StrRetToStrW (ptr ptr ptr) StrRetToStrW
@ stdcall StrRetToStrA (ptr ptr ptr) StrRetToStrA
@ stdcall StrRetToStrW (ptr ptr ptr) StrRetToStrW
@ stdcall SHRegGetPathA(long str str ptr long)SHRegGetPathA
@ stdcall SHRegGetPathW(long wstr wstr ptr long)SHRegGetPathW
@ stub MLLoadLibraryA

View File

@ -37,6 +37,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
HRESULT WINAPI _SHStrDupAA(LPCSTR src, LPSTR * dest);
HRESULT WINAPI _SHStrDupAW(LPCWSTR src, LPSTR * dest);
/*************************************************************************
* ChrCmpIA [SHLWAPI.385]
*
@ -558,6 +561,64 @@ HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest,
return S_OK;
}
/*************************************************************************
* StrRetToStrA [SHLWAPI.@]
*
* converts a STRRET to a normal string
*/
HRESULT WINAPI StrRetToStrA(LPSTRRET pstr, const ITEMIDLIST * pidl, LPSTR* ppszName)
{
HRESULT ret = E_FAIL;
switch (pstr->uType) {
case STRRET_WSTR:
ret = _SHStrDupAW(pstr->u.pOleStr, ppszName);
CoTaskMemFree(pstr->u.pOleStr);
break;
case STRRET_CSTR:
ret = _SHStrDupAA(pstr->u.cStr, ppszName);
break;
case STRRET_OFFSET:
ret = _SHStrDupAA(((LPCSTR)&pidl->mkid)+pstr->u.uOffset, ppszName);
break;
default:
*ppszName = NULL;
}
return ret;
}
/*************************************************************************
* StrRetToStrW [SHLWAPI.@]
*
* converts a STRRET to a normal string
*/
HRESULT WINAPI StrRetToStrW(LPSTRRET pstr, const ITEMIDLIST * pidl, LPWSTR* ppszName)
{
HRESULT ret = E_FAIL;
switch (pstr->uType) {
case STRRET_WSTR:
ret = SHStrDupW(pstr->u.pOleStr, ppszName);
CoTaskMemFree(pstr->u.pOleStr);
break;
case STRRET_CSTR:
ret = SHStrDupA(pstr->u.cStr, ppszName);
break;
case STRRET_OFFSET:
ret = SHStrDupA(((LPCSTR)&pidl->mkid)+pstr->u.uOffset, ppszName);
break;
default:
*ppszName = NULL;
}
return ret;
}
/*************************************************************************
* StrFormatByteSizeA [SHLWAPI.@]
*/
@ -635,6 +696,34 @@ BOOL WINAPI StrTrimA(LPSTR pszSource, LPCSTR pszTrimChars)
return trimmed;
}
/*************************************************************************
* _SHStrDupA [INTERNAL]
*
* Duplicates a ASCII string to ASCII. The destination buffer is allocated.
*/
HRESULT WINAPI _SHStrDupAA(LPCSTR src, LPSTR * dest)
{
HRESULT hr;
int len = 0;
if (src) {
len = lstrlenA(src);
*dest = CoTaskMemAlloc(len);
} else {
*dest = NULL;
}
if (*dest) {
lstrcpynA(*dest,src, len);
hr = S_OK;
} else {
hr = E_OUTOFMEMORY;
}
TRACE("%s->(%p)\n", debugstr_a(src), *dest);
return hr;
}
/*************************************************************************
* SHStrDupA [SHLWAPI.@]
*
@ -663,6 +752,34 @@ HRESULT WINAPI SHStrDupA(LPCSTR src, LPWSTR * dest)
return hr;
}
/*************************************************************************
* _SHStrDupAW [INTERNAL]
*
* Duplicates a UNICODE to a ASCII string. The destination buffer is allocated.
*/
HRESULT WINAPI _SHStrDupAW(LPCWSTR src, LPSTR * dest)
{
HRESULT hr;
int len = 0;
if (src) {
len = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL);
*dest = CoTaskMemAlloc(len);
} else {
*dest = NULL;
}
if (*dest) {
WideCharToMultiByte(CP_ACP, 0, src, -1, *dest, len, NULL, NULL);
hr = S_OK;
} else {
hr = E_OUTOFMEMORY;
}
TRACE("%s->(%p)\n", debugstr_w(src), *dest);
return hr;
}
/*************************************************************************
* SHStrDupW [SHLWAPI.@]
*