发表于:2005-03-09 16:24:00
楼主
我用VC实现的客户端,在基于group 读取数据时出错,查错误码为参数无效,下面是部分代码,请高手指点:
long i;
short iSource;
VARIANT varQuality;
VARIANT varTimeStamp ;
HRESULT hr;
varQuality.vt=VT_I2;
varTimeStamp.vt=VT_DATE;
SAFEARRAY* pHandleArray;
SAFEARRAY* pValueArray;
SAFEARRAY* pErrorArray;
pHandleArray=SafeArrayCreateVector(VT_I4, 0, m_iItemSum);
pValueArray=SafeArrayCreateVector(VT_VARIANT, 0, m_iItemSum);
pErrorArray=SafeArrayCreateVector(VT_I4, 0, m_iItemSum);
if((pHandleArray == NULL)||(pValueArray == NULL)||(pErrorArray == NULL))
{
MessageBox("SafeArrayCreate Error");
return FALSE;
}
for(i=0;i<m_iItemSum;i++)
{
hr=SafeArrayPutElement(pHandleArray, &i, (void*)&m_pItemList[i].m_lServerHandle);
if(!SUCCEEDED(hr)) MessageBox("SafeArrayPutElement Error");
}
iSource=OPCCache;
m_pIOPCGroupPtr->SyncRead(iSource,m_iItemSum,&pHandleArray,&pValueArray,&pErrorArray,&varQuality,&varTimeStamp);