我在接口中定义了一个函数:
interface ImyClass : IDispatch
{
[id(1), helpstring("method sqlExec")] HRESULT sqlExec([in]BSTR code1,[in]BSTR code2,[in]int iM);
};
在类中重载了这个函数
STDMETHODIMP CmyClass::sqlExec(BSTR code1, BSTR code2, int iM)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()) // TODO: Add your implementation code here
    _ConnectionPtr pCon(__uuidof(Connection));
pCon->Open(_T("provider=sqloledb.1;data source=niit-1e3;initial catalog=xuc"),_T("sa"),_T(""),adOpenUnspecified);
_CommandPtr pCmd(__uuidof(Command));
pCmd->ActiveConnection=pCon;
       。。

编译通过,但在VB中引用时提示参数不对。
将原来的函数定义改为:
[id(2), helpstring("method sqlExec1")] HRESULT sqlExec1([in]BSTR code1,[in]BSTR code2,[in]int iM,[out,retval]long *a);
并在函数重载中加上*a=0;
函数就能用了。这是为什么?