I am trying to create an opc client which connects to ofs opc server.
The code for client is below.
This code successfully creates a group in the server but fails to create any items and gives no error.
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (LPVOID*)&pUnkn);
if(SUCCEEDED(hr))
{
hr = pUnkn->QueryInterface(IID_IOPCServer, (LPVOID*)&m_pOpcServer);
hr = pUnkn->QueryInterface(IID_IOPCBrowseServerAddressSpace, (LPVOID*)&m_pOpcBrowse);
hr = m_pOpcServer->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
OPCHANDLE hClientGroup = 0;
DWORD dwUpdateRate = 0;
hr = m_pOpcServer->AddGroup(L"Group1", true, dwUpdateRate, hClientGroup, 0,0, 0, &hClientGroup, &dwUpdateRate, IID_IOPCGroupStateMgt, (IUnknown**)&pInterface);
OPCITEMDEF idef[1] = {{ /*szAccessPath*/ L"",
/*szItemID*/ ITEM_ID,
/*bActive*/ FALSE,
/*hClient*/ 1,
/*dwBlobSize*/ 0,
/*pBlob*/ NULL,
/*vtRequestedDataType*/ VT,
/*wReserved*/0
}};
hr=0;
hr = pInterface->QueryInterface(IID_IOPCItemMgt, reinterpret_cast<LPVOID*>(&ptrItMgm));
if(SUCCEEDED(hr))
{
hr = ptrItMgm->AddItems(1, idef, &pResults, &pErrors);
}
'''