The information in this article applies to:
SUMMARYUsing the #import statement to create your client application introduces exception handling through the _com_error exception class when a wrapper for an object's method encounters a failed HRESULT. You might have valid reasons to replace this mechanism with your own implementation. MORE INFORMATION
There are two ways to use #import and not have it raise exceptions for
failed HRESULTS. The first is simply to use the raw_interfaces_only clause
with the #import statement. However, this negates some of the advantages of
the wrapper classes that #import provides.
This function is declared but not implemented in the Comdef.h file. If you provide your own implementation in an .OBJ file, the linker uses that implementation as opposed to bringing it in from the Comsupp.lib file. _com_raise_error exists in its own object in the Comsupp.lib file so it can be easily replaced by your code. Following is a sample implementation of the #import's exception raising function. NOTE: Currently the compiler ignores a function exception-specification and generates the following warning:
At this time, the implementation details of exception specification have not been standardized, and are accepted but not implemented in Microsoft Visual C++. Code compiled with ignored exception specifications may need to be recompiled and linked to be reused in future versions supporting exception specifications. You can avoid this warning by using the warning pragma:
Sample Code
This code attempts to open an ActiveX Data Objects (ADO) connection object without providing any valid connection information. Replacing _com_raise_error prevented the _com_error from being raised. Additional query words: kbdse kbgrpvcdb kbgrpmdac kbdsupport kbdatabase kbado
Keywords : kbCompiler |
Last Reviewed: November 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |