From fa3e1735152a12a9111c20c16e9a72ba1a913250 Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Sun, 24 Dec 2017 01:28:16 +0100 Subject: [PATCH] [ATL] Add CString.AllocSysString --- sdk/lib/atl/cstringt.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sdk/lib/atl/cstringt.h b/sdk/lib/atl/cstringt.h index b758514ba4f..5d278c5a0ad 100644 --- a/sdk/lib/atl/cstringt.h +++ b/sdk/lib/atl/cstringt.h @@ -143,6 +143,12 @@ public: return ::vswprintf(pszDest, pszFormat, args); } + static BSTR __cdecl AllocSysString( + _In_z_ LPCWSTR pszSource, + _In_ int nLength) + { + return ::SysAllocStringLen(pszSource, nLength); + } }; @@ -269,6 +275,19 @@ public: return ::vsprintf(pszDest, pszFormat, args); } + static BSTR __cdecl AllocSysString( + _In_z_ LPCSTR pszSource, + _In_ int nLength) + { + int nLen = ChTraitsCRT::GetBaseTypeLength(pszSource, nLength); + BSTR bstr = ::SysAllocStringLen(NULL, nLen); + if (bstr) + { + ChTraitsCRT::ConvertToBaseType(bstr, nLen, pszSource, nLength); + } + return bstr; + } + }; @@ -797,8 +816,14 @@ public: } + BSTR AllocSysString() const + { + return StringTraits::AllocSysString(CThisSimpleString::GetString(), CThisSimpleString::GetLength()); + } + + }; } //namespace ATL -#endif \ No newline at end of file +#endif -- 2.17.1