shcore: Add StrDupA()/StrDupW().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-11-28 09:59:03 +03:00 committed by Alexandre Julliard
parent e44a4173cd
commit 0046c1f5bd
2 changed files with 48 additions and 2 deletions

View File

@ -1409,3 +1409,49 @@ BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE thread_proc, void *data, DWORD
return called; return called;
} }
/*************************************************************************
* SHStrDupW [SHCORE.@]
*/
HRESULT WINAPI SHStrDupW(const WCHAR *src, WCHAR **dest)
{
size_t len;
TRACE("(%s, %p)\n", debugstr_w(src), dest);
*dest = NULL;
if (!src)
return E_INVALIDARG;
len = (strlenW(src) + 1) * sizeof(WCHAR);
*dest = CoTaskMemAlloc(len);
if (!*dest)
return E_OUTOFMEMORY;
memcpy(*dest, src, len);
return S_OK;
}
/*************************************************************************
* SHStrDupA [SHCORE.@]
*/
HRESULT WINAPI SHStrDupA(const char *src, WCHAR **dest)
{
DWORD len;
*dest = NULL;
if (!src)
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
*dest = CoTaskMemAlloc(len * sizeof(WCHAR));
if (!*dest)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src, -1, *dest, len);
return S_OK;
}

View File

@ -73,8 +73,8 @@
@ stdcall SHSetThreadRef(ptr) @ stdcall SHSetThreadRef(ptr)
@ stdcall SHSetValueA(long str str long ptr long) shlwapi.SHSetValueA @ stdcall SHSetValueA(long str str long ptr long) shlwapi.SHSetValueA
@ stdcall SHSetValueW(long wstr wstr long ptr long) shlwapi.SHSetValueW @ stdcall SHSetValueW(long wstr wstr long ptr long) shlwapi.SHSetValueW
@ stdcall SHStrDupA(str ptr) shlwapi.SHStrDupA @ stdcall SHStrDupA(str ptr)
@ stdcall SHStrDupW(wstr ptr) shlwapi.SHStrDupW @ stdcall SHStrDupW(wstr ptr)
@ stdcall SHUnicodeToAnsi(wstr ptr ptr) shlwapi.SHUnicodeToAnsi @ stdcall SHUnicodeToAnsi(wstr ptr ptr) shlwapi.SHUnicodeToAnsi
@ stdcall SHUnicodeToUnicode(wstr ptr long) shlwapi.SHUnicodeToUnicode @ stdcall SHUnicodeToUnicode(wstr ptr long) shlwapi.SHUnicodeToUnicode
@ stdcall SetCurrentProcessExplicitAppUserModelID(wstr) @ stdcall SetCurrentProcessExplicitAppUserModelID(wstr)