您现在的位置是:首页 >

vc水怎么使用 IOPCBrowseServerAddressSpace 的使用(vc)

火烧 2022-04-05 20:38:09 1054
IOPCBrow eServerAddre S ace 的使用 vc   在制作 OPC Clie t 的时候通常需要浏览OPC Serve的所有已经定义的item名称(当然OPC Server必须支

IOPCBrowseServerAddressSpace 的使用(vc)  

vc水怎么使用 IOPCBrowseServerAddressSpace 的使用(vc)
  在制作 OPC Client 的时候通常需要浏览OPC Serve的所有已经定义的item名称(当然OPC Server必须支持这个选项) 如果用VC的话就要使用到IOPCBrowseServerAddressSpace接口 那么 下面是提取item目录结构的一个自制的递归函数     void TryBrowseBranch(IOPCBrowseServerAddressSpace *pBSAS LPCWSTR lpprestr LPCWSTR lpcw)  {  HRESULT r ;  OPCNAMESPACETYPE onst;  LPWSTR pItemID;  WCHAR s *lp;  IEnumString *pEnum = ;    char szBuf[ ];  long nPos = ;  HRESULT r = S_OK;  LPOLESTR pStr;  ULONG actual;    lp = WSTRFromSBCS( %ls %ls pIMalloc);  // 向lpcw节点的枝叶改变位置  pBSAS >ChangeBrowsePosition(OPC_BROWSE_DOWN lpcw);  r = pBSAS >BrowseOPCItemIDs(OPC_FLAT &s VT_EMPTY &pEnum);  pBSAS >QueryOrganization(&onst);    // 提取该节点下的所有枝叶  while((r = pEnum >Next( &pStr &actual)) == S_OK)  {  printf( %ls%ls %lsn lpprestr lpcw pStr);  wprintf(lpprestr lp lpcw pStr);  if(onst == OPC_BRANCH)  TryBrowseBranch(pBSAS lpprestr pStr);  }  // pBSAS >ChangeBrowsePosition(OPC_BROWSE_DOWN   // printf( OPC_NS_HIERARCHIAL 含有枝干 );  // get firset item  pIMalloc >Free(lp);  pIMalloc >Free(pStr);  pEnum >Release();  // 回到名叫lpcw的主干位置  pBSAS >ChangeBrowsePosition(OPC_BROWSE_UP lpcw);  } lishixinzhi/Article/program/Java/hx/201311/25685  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码