From 0046c1f5bd55d5f3ba40a760fd6a93bf84f26877 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 28 Nov 2018 09:59:03 +0300 Subject: [PATCH] shcore: Add StrDupA()/StrDupW(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/shcore/main.c | 46 +++++++++++++++++++++++++++++++++++++++++ dlls/shcore/shcore.spec | 4 ++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/dlls/shcore/main.c b/dlls/shcore/main.c index 93effef6ad9..bf477aefcc9 100644 --- a/dlls/shcore/main.c +++ b/dlls/shcore/main.c @@ -1409,3 +1409,49 @@ BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE thread_proc, void *data, DWORD 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; +} diff --git a/dlls/shcore/shcore.spec b/dlls/shcore/shcore.spec index a08c2da7e0e..1473bf7b0a6 100644 --- a/dlls/shcore/shcore.spec +++ b/dlls/shcore/shcore.spec @@ -73,8 +73,8 @@ @ stdcall SHSetThreadRef(ptr) @ stdcall SHSetValueA(long str str long ptr long) shlwapi.SHSetValueA @ stdcall SHSetValueW(long wstr wstr long ptr long) shlwapi.SHSetValueW -@ stdcall SHStrDupA(str ptr) shlwapi.SHStrDupA -@ stdcall SHStrDupW(wstr ptr) shlwapi.SHStrDupW +@ stdcall SHStrDupA(str ptr) +@ stdcall SHStrDupW(wstr ptr) @ stdcall SHUnicodeToAnsi(wstr ptr ptr) shlwapi.SHUnicodeToAnsi @ stdcall SHUnicodeToUnicode(wstr ptr long) shlwapi.SHUnicodeToUnicode @ stdcall SetCurrentProcessExplicitAppUserModelID(wstr)