![]() |
Visual FoxPro OLE IDispatch Error CodeVisual FoxPro 5.0 uses late binding on OLE Automation servers, which means methods and properties are accessed via the Invoke method of the IDispatch interface. As such, VFP receives its error information through the EXCEPINFO structure passed to that method. This structure contains two members that can represent an error code, wCode and scode. The use of wCode dates back to 16-bit OLE implementations; scode is the preferred means by which to return errors. In fact, servers that use error objects and delegate IDispatch::Invoke to ITypeInfo::Invoke will have scode filled by the latter. Servers created with the Active Template Library fall into this category. When VFP detects an error returned from an OLE Automation server, i.e. IDispatch::Invoke returns DISP_E_EXCEPTION, it generates a FoxPro error. Unfortunately, this error always reports the wCode and never the scode. Therefore, it is quite common to see VFP report an IDispatch error 0. Visual Basic 5.0 checks scode first, then wCode if scode is 0. Of course, VB also supports early binding via type libraries. In this case, it gets error information directly from IErrorInfo.
Copyright © 1997 Scott Nichol. 06-Nov-97 |