前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >制作opc服务器,力控服务器怎样做为OPC服务器,供其他OPC客户端程序访问

制作opc服务器,力控服务器怎样做为OPC服务器,供其他OPC客户端程序访问

作者头像
全栈程序员站长
发布2022-08-31 15:11:19
3.9K0
发布2022-08-31 15:11:19
举报

大家好,又见面了,我是你们的朋友全栈君。

public void ListAll(Guid catid, out OpcServers[] serverslist)

{

serverslist = null;

Dispose();

Guid guid = new Guid(13486D51-4821-11D2-A494-3CB306C10000);

Type typeoflist = Type.GetTypeFromCLSID(guid);

OPCListObj = Activator.CreateInstance(typeoflist);

ifList = (IOPCServerList)OPCListObj;

if (ifList == null)

Marshal.ThrowExceptionForHR(HRESULTS.E_ABORT);

ifList.EnumClassesOfCategories(1, ref catid, 0, ref catid, out EnumObj);

if (EnumObj == null)

Marshal.ThrowExceptionForHR(HRESULTS.E_ABORT);

ifEnum = (IEnumGUID)EnumObj;

if (ifEnum == null)

Marshal.ThrowExceptionForHR(HRESULTS.E_ABORT);

int maxcount = 300;

IntPtr ptrGuid = Marshal.AllocCoTaskMem(maxcount * 16);

int count = 0;

ifEnum.Next(maxcount, ptrGuid, out count);

if (count 1)

{ Marshal.FreeCoTaskMem(ptrGuid); return; }

serverslist = new OpcServers[count];

byte[] guidbin = new byte[16];

int runGuid = (int)ptrGuid;

for (int i = 0; i count; i++)

{

serverslist[i] = new OpcServers();

Marshal.Copy((IntPtr)runGuid, guidbin, 0, 16);

serverslist[i].ClsID = new Guid(guidbin);

ifList.GetClassDetails(ref serverslist[i].ClsID,

out serverslist[i].ProgID, out serverslist[i].ServerName);

runGuid += 16;

}

Marshal.FreeCoTaskMem(ptrGuid);

Dispose();

}

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151317.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档