2000-02-26 19:33:21 +01:00
|
|
|
/*
|
|
|
|
* ErrorInfo API
|
|
|
|
*
|
2000-08-03 06:34:59 +02:00
|
|
|
* Copyright 2000 Patrik Stridvall, Juergen Schmied
|
2000-02-26 19:33:21 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* NOTES:
|
2000-06-12 23:56:02 +02:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* The errorinfo is a per-thread object. The reference is stored in the
|
2005-01-05 18:14:33 +01:00
|
|
|
* TEB at offset 0xf80.
|
2000-02-26 19:33:21 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2004-08-11 21:43:45 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2000-02-26 19:33:21 +01:00
|
|
|
#include "windef.h"
|
2001-07-25 02:43:29 +02:00
|
|
|
#include "winbase.h"
|
2004-08-22 23:38:46 +02:00
|
|
|
#include "objbase.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "oleauto.h"
|
2000-02-26 19:33:21 +01:00
|
|
|
#include "winerror.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2000-09-23 00:07:53 +02:00
|
|
|
#include "wine/unicode.h"
|
2003-06-04 22:11:34 +02:00
|
|
|
#include "compobj_private.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-09-23 00:07:53 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
2000-09-23 00:07:53 +02:00
|
|
|
|
2012-07-19 11:49:09 +02:00
|
|
|
static inline WCHAR *heap_strdupW(const WCHAR *str)
|
|
|
|
{
|
|
|
|
WCHAR *ret = NULL;
|
|
|
|
|
|
|
|
if(str) {
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
size = (strlenW(str)+1)*sizeof(WCHAR);
|
|
|
|
ret = heap_alloc(size);
|
|
|
|
if(ret)
|
|
|
|
memcpy(ret, str, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-03 06:34:59 +02:00
|
|
|
typedef struct ErrorInfoImpl
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
IErrorInfo IErrorInfo_iface;
|
|
|
|
ICreateErrorInfo ICreateErrorInfo_iface;
|
|
|
|
ISupportErrorInfo ISupportErrorInfo_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
GUID m_Guid;
|
2012-07-19 11:49:09 +02:00
|
|
|
WCHAR *source;
|
2012-07-19 11:49:22 +02:00
|
|
|
WCHAR *description;
|
2012-07-19 11:49:33 +02:00
|
|
|
WCHAR *help_file;
|
2012-07-17 09:14:12 +02:00
|
|
|
DWORD m_dwHelpContext;
|
2000-08-03 06:34:59 +02:00
|
|
|
} ErrorInfoImpl;
|
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
static inline ErrorInfoImpl *impl_from_IErrorInfo( IErrorInfo *iface )
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
return CONTAINING_RECORD(iface, ErrorInfoImpl, IErrorInfo_iface);
|
2005-07-27 13:10:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ErrorInfoImpl *impl_from_ICreateErrorInfo( ICreateErrorInfo *iface )
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
return CONTAINING_RECORD(iface, ErrorInfoImpl, ICreateErrorInfo_iface);
|
2005-07-27 13:10:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ErrorInfoImpl *impl_from_ISupportErrorInfo( ISupportErrorInfo *iface )
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
return CONTAINING_RECORD(iface, ErrorInfoImpl, ISupportErrorInfo_iface);
|
2005-07-27 13:10:52 +02:00
|
|
|
}
|
2000-08-03 06:34:59 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI IErrorInfoImpl_QueryInterface(
|
|
|
|
IErrorInfo* iface,
|
|
|
|
REFIID riid,
|
2012-07-17 09:14:12 +02:00
|
|
|
void** ppvoid)
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2012-07-17 09:14:12 +02:00
|
|
|
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid),ppvoid);
|
2000-08-03 06:34:59 +02:00
|
|
|
|
|
|
|
*ppvoid = NULL;
|
|
|
|
|
2012-07-17 09:22:59 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IErrorInfo))
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
*ppvoid = &This->IErrorInfo_iface;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
*ppvoid = &This->ICreateErrorInfo_iface;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
*ppvoid = &This->ISupportErrorInfo_iface;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppvoid)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef( (IUnknown*)*ppvoid );
|
|
|
|
TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IErrorInfoImpl_AddRef(
|
|
|
|
IErrorInfo* iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n",This,This->ref);
|
2000-08-03 06:34:59 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IErrorInfoImpl_Release(
|
|
|
|
IErrorInfo* iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2005-01-09 18:29:21 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n",This,ref+1);
|
2000-08-03 06:34:59 +02:00
|
|
|
|
2005-01-09 18:29:21 +01:00
|
|
|
if (!ref)
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
|
|
|
TRACE("-- destroying IErrorInfo(%p)\n",This);
|
2009-12-09 15:06:03 +01:00
|
|
|
|
2012-07-19 11:49:09 +02:00
|
|
|
heap_free(This->source);
|
2012-07-19 11:49:22 +02:00
|
|
|
heap_free(This->description);
|
2012-07-19 11:49:33 +02:00
|
|
|
heap_free(This->help_file);
|
|
|
|
heap_free(This);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
2005-01-09 18:29:21 +01:00
|
|
|
return ref;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IErrorInfoImpl_GetGUID(
|
|
|
|
IErrorInfo* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
GUID * pGUID)
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n",This,This->ref);
|
2000-09-23 00:07:53 +02:00
|
|
|
if(!pGUID )return E_INVALIDARG;
|
2008-03-10 22:58:39 +01:00
|
|
|
*pGUID = This->m_Guid;
|
2000-08-03 06:34:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IErrorInfoImpl_GetSource(
|
|
|
|
IErrorInfo* iface,
|
|
|
|
BSTR *pBstrSource)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2000-09-23 00:07:53 +02:00
|
|
|
TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
|
|
|
|
if (pBstrSource == NULL)
|
|
|
|
return E_INVALIDARG;
|
2012-07-19 11:49:09 +02:00
|
|
|
*pBstrSource = SysAllocString(This->source);
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IErrorInfoImpl_GetDescription(
|
|
|
|
IErrorInfo* iface,
|
|
|
|
BSTR *pBstrDescription)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2000-09-23 00:07:53 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
|
|
|
|
if (pBstrDescription == NULL)
|
|
|
|
return E_INVALIDARG;
|
2012-07-19 11:49:22 +02:00
|
|
|
*pBstrDescription = SysAllocString(This->description);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(
|
|
|
|
IErrorInfo* iface,
|
|
|
|
BSTR *pBstrHelpFile)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2000-09-23 00:07:53 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
|
|
|
|
if (pBstrHelpFile == NULL)
|
|
|
|
return E_INVALIDARG;
|
2012-07-19 11:49:33 +02:00
|
|
|
*pBstrHelpFile = SysAllocString(This->help_file);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IErrorInfoImpl_GetHelpContext(
|
|
|
|
IErrorInfo* iface,
|
|
|
|
DWORD *pdwHelpContext)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
|
2000-09-23 00:07:53 +02:00
|
|
|
TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
|
|
|
|
if (pdwHelpContext == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pdwHelpContext = This->m_dwHelpContext;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
2012-07-17 09:14:12 +02:00
|
|
|
static const IErrorInfoVtbl ErrorInfoVtbl =
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
|
|
|
IErrorInfoImpl_QueryInterface,
|
|
|
|
IErrorInfoImpl_AddRef,
|
|
|
|
IErrorInfoImpl_Release,
|
|
|
|
IErrorInfoImpl_GetGUID,
|
|
|
|
IErrorInfoImpl_GetSource,
|
|
|
|
IErrorInfoImpl_GetDescription,
|
|
|
|
IErrorInfoImpl_GetHelpFile,
|
|
|
|
IErrorInfoImpl_GetHelpContext
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface(
|
|
|
|
ICreateErrorInfo* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
|
|
|
return IErrorInfo_QueryInterface(&This->IErrorInfo_iface, riid, ppvoid);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ICreateErrorInfoImpl_AddRef(
|
|
|
|
ICreateErrorInfo* iface)
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
|
|
|
return IErrorInfo_AddRef(&This->IErrorInfo_iface);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ICreateErrorInfoImpl_Release(
|
|
|
|
ICreateErrorInfo* iface)
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
|
|
|
return IErrorInfo_Release(&This->IErrorInfo_iface);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID(
|
|
|
|
ICreateErrorInfo* iface,
|
|
|
|
REFGUID rguid)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
2000-08-03 06:34:59 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
|
2008-03-10 22:58:39 +01:00
|
|
|
This->m_Guid = *rguid;
|
2000-08-03 06:34:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ICreateErrorInfoImpl_SetSource(
|
|
|
|
ICreateErrorInfo* iface,
|
|
|
|
LPOLESTR szSource)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
2004-11-29 18:00:39 +01:00
|
|
|
TRACE("(%p): %s\n",This, debugstr_w(szSource));
|
2012-07-19 11:49:09 +02:00
|
|
|
|
|
|
|
heap_free(This->source);
|
|
|
|
This->source = heap_strdupW(szSource);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription(
|
|
|
|
ICreateErrorInfo* iface,
|
|
|
|
LPOLESTR szDescription)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
2004-11-29 18:00:39 +01:00
|
|
|
TRACE("(%p): %s\n",This, debugstr_w(szDescription));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2012-07-19 11:49:22 +02:00
|
|
|
heap_free(This->description);
|
|
|
|
This->description = heap_strdupW(szDescription);
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(
|
|
|
|
ICreateErrorInfo* iface,
|
|
|
|
LPOLESTR szHelpFile)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
2005-02-14 12:07:55 +01:00
|
|
|
TRACE("(%p,%s)\n",This,debugstr_w(szHelpFile));
|
2012-07-19 11:49:33 +02:00
|
|
|
heap_free(This->help_file);
|
|
|
|
This->help_file = heap_strdupW(szHelpFile);
|
2000-09-23 00:07:53 +02:00
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext(
|
|
|
|
ICreateErrorInfo* iface,
|
|
|
|
DWORD dwHelpContext)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p,%d)\n",This,dwHelpContext);
|
2000-09-23 00:07:53 +02:00
|
|
|
This->m_dwHelpContext = dwHelpContext;
|
|
|
|
return S_OK;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
2012-07-17 09:14:12 +02:00
|
|
|
static const ICreateErrorInfoVtbl CreateErrorInfoVtbl =
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
|
|
|
ICreateErrorInfoImpl_QueryInterface,
|
|
|
|
ICreateErrorInfoImpl_AddRef,
|
|
|
|
ICreateErrorInfoImpl_Release,
|
|
|
|
ICreateErrorInfoImpl_SetGUID,
|
|
|
|
ICreateErrorInfoImpl_SetSource,
|
|
|
|
ICreateErrorInfoImpl_SetDescription,
|
|
|
|
ICreateErrorInfoImpl_SetHelpFile,
|
|
|
|
ICreateErrorInfoImpl_SetHelpContext
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface(
|
|
|
|
ISupportErrorInfo* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
return IErrorInfo_QueryInterface(&This->IErrorInfo_iface, riid, ppvoid);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
2012-07-17 09:14:12 +02:00
|
|
|
static ULONG WINAPI ISupportErrorInfoImpl_AddRef(ISupportErrorInfo* iface)
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
return IErrorInfo_AddRef(&This->IErrorInfo_iface);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
2012-07-17 09:14:12 +02:00
|
|
|
static ULONG WINAPI ISupportErrorInfoImpl_Release(ISupportErrorInfo* iface)
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
2012-07-17 09:14:12 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
return IErrorInfo_Release(&This->IErrorInfo_iface);
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo(
|
|
|
|
ISupportErrorInfo* iface,
|
|
|
|
REFIID riid)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
|
2000-08-03 06:34:59 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
|
2000-09-23 00:07:53 +02:00
|
|
|
return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
|
2000-08-03 06:34:59 +02:00
|
|
|
}
|
|
|
|
|
2012-07-17 09:14:12 +02:00
|
|
|
static const ISupportErrorInfoVtbl SupportErrorInfoVtbl =
|
2000-08-03 06:34:59 +02:00
|
|
|
{
|
|
|
|
ISupportErrorInfoImpl_QueryInterface,
|
|
|
|
ISupportErrorInfoImpl_AddRef,
|
|
|
|
ISupportErrorInfoImpl_Release,
|
|
|
|
ISupportErrorInfoImpl_InterfaceSupportsErrorInfo
|
|
|
|
};
|
2007-05-08 01:02:06 +02:00
|
|
|
|
2012-07-17 09:14:12 +02:00
|
|
|
static IErrorInfo* IErrorInfoImpl_Constructor(void)
|
|
|
|
{
|
2012-07-19 11:49:09 +02:00
|
|
|
ErrorInfoImpl *This = heap_alloc(sizeof(ErrorInfoImpl));
|
2012-07-17 09:14:12 +02:00
|
|
|
|
|
|
|
if (!This) return NULL;
|
|
|
|
|
|
|
|
This->IErrorInfo_iface.lpVtbl = &ErrorInfoVtbl;
|
|
|
|
This->ICreateErrorInfo_iface.lpVtbl = &CreateErrorInfoVtbl;
|
|
|
|
This->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
|
|
|
|
This->ref = 1;
|
2012-07-19 11:49:09 +02:00
|
|
|
This->source = NULL;
|
2012-07-19 11:49:22 +02:00
|
|
|
This->description = NULL;
|
2012-07-19 11:49:33 +02:00
|
|
|
This->help_file = NULL;
|
2012-07-17 09:14:12 +02:00
|
|
|
This->m_dwHelpContext = 0;
|
|
|
|
|
|
|
|
return &This->IErrorInfo_iface;
|
|
|
|
}
|
|
|
|
|
2000-02-26 19:33:21 +01:00
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* CreateErrorInfo (OLE32.@)
|
2007-05-08 01:02:06 +02:00
|
|
|
*
|
|
|
|
* Creates an object used to set details for an error info object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pperrinfo [O]. Address where error info creation object will be stored.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: HRESULT code.
|
2000-02-26 19:33:21 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **pperrinfo)
|
|
|
|
{
|
2000-08-03 06:34:59 +02:00
|
|
|
IErrorInfo * pei;
|
|
|
|
HRESULT res;
|
2005-12-12 11:52:36 +01:00
|
|
|
TRACE("(%p)\n", pperrinfo);
|
2000-09-23 00:07:53 +02:00
|
|
|
if(! pperrinfo ) return E_INVALIDARG;
|
2000-08-03 06:34:59 +02:00
|
|
|
if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-03 06:34:59 +02:00
|
|
|
res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
|
|
|
|
IErrorInfo_Release(pei);
|
|
|
|
return res;
|
2000-02-26 19:33:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* GetErrorInfo (OLE32.@)
|
2007-05-08 01:02:06 +02:00
|
|
|
*
|
|
|
|
* Retrieves the error information object for the current thread.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* dwReserved [I]. Reserved. Must be zero.
|
|
|
|
* pperrinfo [O]. Address where error information object will be stored on return.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK if an error information object was set for the current thread.
|
|
|
|
* S_FALSE if otherwise.
|
|
|
|
* Failure: E_INVALIDARG if dwReserved is not zero.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This function causes the current error info object for the thread to be
|
|
|
|
* cleared if one was set beforehand.
|
2000-02-26 19:33:21 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetErrorInfo(ULONG dwReserved, IErrorInfo **pperrinfo)
|
|
|
|
{
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%d, %p, %p)\n", dwReserved, pperrinfo, COM_CurrentInfo()->errorinfo);
|
2000-08-03 06:34:59 +02:00
|
|
|
|
2007-01-10 23:56:30 +01:00
|
|
|
if (dwReserved)
|
|
|
|
{
|
|
|
|
ERR("dwReserved (0x%x) != 0\n", dwReserved);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2004-02-10 02:36:20 +01:00
|
|
|
if(!pperrinfo) return E_INVALIDARG;
|
2007-01-10 23:56:30 +01:00
|
|
|
|
2005-01-05 18:14:33 +01:00
|
|
|
if (!COM_CurrentInfo()->errorinfo)
|
2004-02-10 02:36:20 +01:00
|
|
|
{
|
|
|
|
*pperrinfo = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-05 18:14:33 +01:00
|
|
|
*pperrinfo = COM_CurrentInfo()->errorinfo;
|
|
|
|
|
2000-08-03 06:34:59 +02:00
|
|
|
/* clear thread error state */
|
2005-01-05 18:14:33 +01:00
|
|
|
COM_CurrentInfo()->errorinfo = NULL;
|
2000-08-03 06:34:59 +02:00
|
|
|
return S_OK;
|
2000-02-26 19:33:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* SetErrorInfo (OLE32.@)
|
2007-05-08 01:02:06 +02:00
|
|
|
*
|
|
|
|
* Sets the error information object for the current thread.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* dwReserved [I] Reserved. Must be zero.
|
|
|
|
* perrinfo [I] Error info object.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_INVALIDARG if dwReserved is not zero.
|
2000-02-26 19:33:21 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo)
|
|
|
|
{
|
2000-08-03 06:34:59 +02:00
|
|
|
IErrorInfo * pei;
|
2004-02-10 02:36:20 +01:00
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%d, %p)\n", dwReserved, perrinfo);
|
2007-01-10 23:56:30 +01:00
|
|
|
|
|
|
|
if (dwReserved)
|
|
|
|
{
|
|
|
|
ERR("dwReserved (0x%x) != 0\n", dwReserved);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2000-08-03 06:34:59 +02:00
|
|
|
/* release old errorinfo */
|
2005-01-05 18:14:33 +01:00
|
|
|
pei = COM_CurrentInfo()->errorinfo;
|
|
|
|
if (pei) IErrorInfo_Release(pei);
|
2000-08-03 06:34:59 +02:00
|
|
|
|
|
|
|
/* set to new value */
|
2005-01-05 18:14:33 +01:00
|
|
|
COM_CurrentInfo()->errorinfo = perrinfo;
|
|
|
|
if (perrinfo) IErrorInfo_AddRef(perrinfo);
|
|
|
|
|
2000-08-03 06:34:59 +02:00
|
|
|
return S_OK;
|
2000-02-26 19:33:21 +01:00
|
|
|
}
|