18#pragma push_macro("new")
26#define WINAPI __stdcall
32template<
typename _Interface,const IID *_IID >
36 static _Interface *GetInterfacePtr() throw() {
return NULL; }
37 static _Interface& GetInterface() throw() {
return *GetInterfacePtr(); }
38 static const IID& GetIID() throw() {
return *
_IID; }
41template<
typename _IIID>
class _com_ptr_t {
43 typedef _IIID ThisIIID;
44 typedef typename _IIID::Interface
Interface;
45 static const IID& GetIID() throw() {
return ThisIIID::GetIID(); }
46 template<
typename _OtherIID> _com_ptr_t(
const _com_ptr_t<_OtherIID> &
p) : m_pInterface(
NULL) {
50 template<
typename _InterfaceType> _com_ptr_t(_InterfaceType *
p) : m_pInterface(
NULL) {
56 template<
typename _X>
explicit _com_ptr_t(_com_ptr_t *
p) : m_pInterface(
NULL) {
59 m_pInterface =
p->m_pInterface;
63 _com_ptr_t() throw() : m_pInterface(
NULL) { }
64 _com_ptr_t(
int null) : m_pInterface(
NULL) {
68#ifdef _NATIVE_NULLPTR_SUPPORTED
69 _com_ptr_t(
decltype(
nullptr)) : m_pInterface(
NULL) {}
72 _com_ptr_t(
const _com_ptr_t &
cp)
throw() : m_pInterface(
cp.m_pInterface) { _AddRef(); }
75 if(fAddRef) _AddRef();
77 _com_ptr_t(
const _variant_t& varSrc) : m_pInterface(
NULL) {
93 template<
typename _OtherIID> _com_ptr_t &operator=(
const _com_ptr_t<_OtherIID> &
p) {
98 template<
typename _InterfaceType> _com_ptr_t &operator=(_InterfaceType *
p) {
108 if(pOldInterface!=
NULL) pOldInterface->Release();
112 _com_ptr_t &operator=(
const _com_ptr_t &
cp)
throw() {
return operator=(
cp.m_pInterface); }
113 _com_ptr_t &operator=(
int null) {
117 _com_ptr_t &operator=(
const _variant_t& varSrc) {
122 ~_com_ptr_t() throw() { _Release(); }
140 operator Interface*()
const throw() {
return m_pInterface; }
143 return *m_pInterface;
147 return *m_pInterface;
152 return &m_pInterface;
158 operator bool()
const throw() {
return m_pInterface!=
NULL; }
159 template<
typename _OtherIID>
bool operator==(
const _com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)==0; }
160 template<
typename _OtherIID>
bool operator==(_com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)==0; }
161 template<
typename _InterfaceType>
bool operator==(_InterfaceType *
p) {
return _CompareUnknown(
p)==0; }
167 return !m_pInterface;
173 template<
typename _OtherIID>
bool operator<(
const _com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)<0; }
174 template<
typename _OtherIID>
bool operator<(_com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)<0; }
175 template<
typename _InterfaceType>
bool operator<(_InterfaceType *
p) {
return _CompareUnknown(
p)<0; }
176 template<
typename _OtherIID>
bool operator>(
const _com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)>0; }
177 template<
typename _OtherIID>
bool operator>(_com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)>0; }
178 template<
typename _InterfaceType>
bool operator>(_InterfaceType *
p) {
return _CompareUnknown(
p)>0; }
179 template<
typename _OtherIID>
bool operator<=(
const _com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)<=0; }
180 template<
typename _OtherIID>
bool operator<=(_com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)<=0; }
181 template<
typename _InterfaceType>
bool operator<=(_InterfaceType *
p) {
return _CompareUnknown(
p)<=0; }
182 template<
typename _OtherIID>
bool operator>=(
const _com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)>=0; }
183 template<
typename _OtherIID>
bool operator>=(_com_ptr_t<_OtherIID> &
p) {
return _CompareUnknown(
p)>=0; }
184 template<
typename _InterfaceType>
bool operator>=(_InterfaceType *
p) {
return _CompareUnknown(
p)>=0; }
188 m_pInterface->Release();
194 else m_pInterface->AddRef();
196 Interface *GetInterfacePtr()
const throw() {
return m_pInterface; }
197 Interface*& GetInterfacePtr() throw() {
return m_pInterface; }
201 if(dwClsContext & (CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)) {
209 }
else hr =
CoCreateInstance(rclsid,pOuter,dwClsContext,GetIID(),
reinterpret_cast<void**
>(&m_pInterface));
220 return CreateInstance(
clsid,pOuter,dwClsContext);
234 HRESULT hr=CreateInstance(clsidStringW,pOuter,dwClsContext);
243 hr = pIUnknown->
QueryInterface(GetIID(),
reinterpret_cast<void**
>(&m_pInterface));
264 clsidStringW =
static_cast<LPWSTR>(_alloca(destSize*
sizeof(
WCHAR)));
273 if(m_pInterface!=
NULL)
return m_pInterface->
QueryInterface(iid,
reinterpret_cast<void**
>(&
p));
279 void _Release() throw() {
280 if(m_pInterface!=
NULL) m_pInterface->Release();
282 void _AddRef() throw() {
283 if(m_pInterface!=
NULL) m_pInterface->AddRef();
285 template<
typename _InterfacePtr>
HRESULT _QueryInterface(_InterfacePtr
p)
throw() {
297 template<
typename _InterfacePtr>
int _CompareUnknown(_InterfacePtr
p) {
299 if(m_pInterface!=
NULL) {
315 HRESULT QueryStdInterfaces(
const _variant_t& varSrc)
throw() {
332template<
typename _InterfaceType>
bool operator==(
int null,_com_ptr_t<_InterfaceType> &
p) {
337template<
typename _Interface,
typename _InterfacePtr>
bool operator==(_Interface *
i,_com_ptr_t<_InterfacePtr> &
p) {
return p==
i; }
339template<
typename _Interface>
bool operator!=(
int null,_com_ptr_t<_Interface> &
p) {
344template<
typename _Interface,
typename _InterfacePtr>
bool operator!=(_Interface *
i,_com_ptr_t<_InterfacePtr> &
p) {
return p!=
i; }
346template<
typename _Interface>
bool operator<(
int null,_com_ptr_t<_Interface> &
p) {
351template<
typename _Interface,
typename _InterfacePtr>
bool operator<(_Interface *
i,_com_ptr_t<_InterfacePtr> &
p) {
return p>
i; }
353template<
typename _Interface>
bool operator>(
int null,_com_ptr_t<_Interface> &
p) {
358template<
typename _Interface,
typename _InterfacePtr>
bool operator>(_Interface *
i,_com_ptr_t<_InterfacePtr> &
p) {
return p<
i; }
360template<
typename _Interface>
bool operator<=(
int null,_com_ptr_t<_Interface> &
p) {
365template<
typename _Interface,
typename _InterfacePtr>
bool operator<=(_Interface *
i,_com_ptr_t<_InterfacePtr> &
p) {
return p>=
i; }
367template<
typename _Interface>
bool operator>=(
int null,_com_ptr_t<_Interface> &
p) {
372template<
typename _Interface,
typename _InterfacePtr>
bool operator>=(_Interface *
i,_com_ptr_t<_InterfacePtr> &
p) {
return p<=
i; }
374#pragma pop_macro("new")
bool _STLP_CALL operator!=(const allocator< _T1 > &, const allocator< _T2 > &) _STLP_NOTHROW
bitset< _Nb > _STLP_CALL operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y)
bool _STLP_CALL operator>(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
bool _STLP_CALL operator>=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
bool _STLP_CALL operator<=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
complex< _Tp > _STLP_CALL operator*(const _Tp &__x, const complex< _Tp > &__z)
void WINAPI _com_issue_error(HRESULT hr)
#define MultiByteToWideChar
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, LPCLSID clsid)
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
HRESULT WINAPI DECLSPEC_HOTPATCH OleRun(LPUNKNOWN pUnknown)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
int WINAPI lstrlenA(LPCSTR lpString)
static __inline void __cdecl _freea(void *_Memory)
static HRESULT QueryInterface(REFIID, void **)
static ULONG WINAPI AddRef(IStream *iface)
HRESULT WINAPI DECLSPEC_HOTPATCH GetActiveObject(REFCLSID rcid, LPVOID preserved, LPUNKNOWN *ppunk)
bool operator<(const TKeyDef &t1, const TKeyDef &t2)
bool operator==(const TKeyDef &t1, const TKeyDef &t2)
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
void WINAPI VariantInit(VARIANTARG *pVarg)
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
DWORD WINAPI GetLastError(void)
#define HRESULT_FROM_WIN32(x)