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
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|