12098d36a53253b2526b5fd077ce2f86bfd6aa56
4 * Copyright 2009 Andrew Hill <ash77@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 // It is common to use this in ATL constructors. They only store this for later use, so the usage is safe.
28 #pragma warning(disable:4355)
32 #define _ATL_PACKING 8
35 #ifndef _ATL_FREE_THREADED
36 #ifndef _ATL_APARTMENT_THREADED
37 #ifndef _ATL_SINGLE_THREADED
38 #define _ATL_FREE_THREADED
47 #ifdef _ATL_DISABLE_NO_VTABLE
50 #define ATL_NO_VTABLE __declspec(novtable)
75 CComPtr(const CComPtr
<T
> &lp
)
98 T
*operator = (const CComPtr
<T
> &lp
)
135 ATLASSERT(p
== NULL
);
146 ATLASSERT(p
!= NULL
);
162 CComBSTR(LPCOLESTR pSrc
)
167 m_str
= ::SysAllocString(pSrc
);
175 m_str
= ::SysAllocStringLen(NULL
, length
);
178 CComBSTR(int length
, LPCOLESTR pSrc
)
183 m_str
= ::SysAllocStringLen(pSrc
, length
);
190 int len
= MultiByteToWideChar(CP_THREAD_ACP
, 0, pSrc
, -1, NULL
, 0);
191 m_str
= ::SysAllocStringLen(NULL
, len
- 1);
194 int res
= MultiByteToWideChar(CP_THREAD_ACP
, 0, pSrc
, -1, m_str
, len
);
195 ATLASSERT(res
== len
);
198 ::SysFreeString(m_str
);
209 CComBSTR(const CComBSTR
&other
)
211 m_str
= other
.Copy();
214 CComBSTR(REFGUID guid
)
217 ::StringFromGUID2(guid
, szGuid
, 40);
218 m_str
= ::SysAllocString(szGuid
);
223 ::SysFreeString(m_str
);
227 operator BSTR () const
237 CComBSTR
&operator = (const CComBSTR
&other
)
239 ::SysFreeString(m_str
);
240 m_str
= other
.Copy();
248 return ::SysAllocStringLen(m_str
, ::SysStringLen(m_str
));
251 HRESULT
CopyTo(BSTR
*other
) const
259 bool LoadString(HMODULE module
, DWORD uID
)
261 ::SysFreeString(m_str
);
263 const wchar_t *ptr
= NULL
;
264 int len
= ::LoadStringW(module
, uID
, (PWSTR
)&ptr
, 0);
266 m_str
= ::SysAllocStringLen(ptr
, len
);
267 return m_str
!= NULL
;
270 unsigned int Length() const
272 return ::SysStringLen(m_str
);
275 unsigned int ByteLength() const
277 return ::SysStringByteLen(m_str
);
282 class CComVariant
: public tagVARIANT
297 return ::VariantClear(this);
305 #ifndef _ATL_NO_AUTOMATIC_NAMESPACE
307 #endif //!_ATL_NO_AUTOMATIC_NAMESPACE