public void Next(int enumcountmax, out OPCItemAttributes[] attributes) { attributes = null; IntPtr ptrAtt; int count; ifEnum.Next(enumcountmax, out ptrAtt, out count); int runatt = (int)ptrAtt; if ((runatt == 0) || (count <= 0) || (count > enumcountmax)) { return; } attributes = new OPCItemAttributes[count]; IntPtr ptrString; for (int i = 0; i < count; i++) { attributes[i] = new OPCItemAttributes(); ptrString = (IntPtr)Marshal.ReadInt32((IntPtr)runatt); attributes[i].AccessPath = Marshal.PtrToStringUni(ptrString); Marshal.FreeCoTaskMem(ptrString); ptrString = (IntPtr)Marshal.ReadInt32((IntPtr)(runatt + 4)); attributes[i].ItemID = Marshal.PtrToStringUni(ptrString); Marshal.FreeCoTaskMem(ptrString); attributes[i].Active = (Marshal.ReadInt32((IntPtr)(runatt + 8))) != 0; attributes[i].HandleClient = Marshal.ReadInt32((IntPtr)(runatt + 12)); attributes[i].HandleServer = Marshal.ReadInt32((IntPtr)(runatt + 16)); attributes[i].AccessRights = (OPCACCESSRIGHTS)Marshal.ReadInt32((IntPtr)(runatt + 20)); attributes[i].RequestedDataType = (VarEnum)Marshal.ReadInt16((IntPtr)(runatt + 32)); attributes[i].CanonicalDataType = (VarEnum)Marshal.ReadInt16((IntPtr)(runatt + 34)); attributes[i].EUType = (OPCEUTYPE)Marshal.ReadInt32((IntPtr)(runatt + 36)); attributes[i].EUInfo = Marshal.GetObjectForNativeVariant((IntPtr)(runatt + 40)); DUMMY_VARIANT.VariantClear((IntPtr)(runatt + 40)); int ptrblob = Marshal.ReadInt32((IntPtr)(runatt + 28)); if ((ptrblob != 0)) { int blobsize = Marshal.ReadInt32((IntPtr)(runatt + 24)); if (blobsize > 0) { attributes[i].Blob = new byte[blobsize]; Marshal.Copy((IntPtr)ptrblob, attributes[i].Blob, 0, blobsize); } Marshal.FreeCoTaskMem((IntPtr)ptrblob); } runatt += 56; } Marshal.FreeCoTaskMem(ptrAtt); }
public void Next( int enumcountmax, out OPCItemAttributes[] attributes ) { attributes = null; IntPtr ptrAtt; int count; ifEnum.Next( enumcountmax, out ptrAtt, out count ); int runatt = (int) ptrAtt; if( (runatt == 0) || (count <= 0) || (count > enumcountmax) ) return; attributes = new OPCItemAttributes[ count ]; IntPtr ptrString; for( int i = 0; i < count; i++ ) { attributes[i] = new OPCItemAttributes(); ptrString = (IntPtr) Marshal.ReadInt32( (IntPtr) runatt ); attributes[i].AccessPath = Marshal.PtrToStringUni( ptrString ); Marshal.FreeCoTaskMem( ptrString ); ptrString = (IntPtr) Marshal.ReadInt32( (IntPtr)(runatt + 4) ); attributes[i].ItemID = Marshal.PtrToStringUni( ptrString ); Marshal.FreeCoTaskMem( ptrString ); attributes[i].Active = (Marshal.ReadInt32( (IntPtr)(runatt + 8) )) != 0; attributes[i].HandleClient = Marshal.ReadInt32( (IntPtr)(runatt + 12) ); attributes[i].HandleServer = Marshal.ReadInt32( (IntPtr)(runatt + 16) ); attributes[i].AccessRights = (OPCACCESSRIGHTS) Marshal.ReadInt32( (IntPtr)(runatt + 20) ); attributes[i].RequestedDataType = (VarEnum) Marshal.ReadInt16( (IntPtr)(runatt + 32) ); attributes[i].CanonicalDataType = (VarEnum) Marshal.ReadInt16( (IntPtr)(runatt + 34) ); attributes[i].EUType = (OPCEUTYPE) Marshal.ReadInt32( (IntPtr)(runatt + 36) ); attributes[i].EUInfo = Marshal.GetObjectForNativeVariant( (IntPtr)(runatt + 40) ); DUMMY_VARIANT.VariantClear( (IntPtr) (runatt + 40) ); int ptrblob = Marshal.ReadInt32( (IntPtr)(runatt + 28) ); if( (ptrblob != 0) ) { int blobsize = Marshal.ReadInt32( (IntPtr)(runatt + 24) ); if( blobsize > 0 ) { attributes[i].Blob = new byte[ blobsize ]; Marshal.Copy( (IntPtr) ptrblob, attributes[i].Blob, 0, blobsize ); } Marshal.FreeCoTaskMem( (IntPtr) ptrblob ); } runatt += 56; } Marshal.FreeCoTaskMem( ptrAtt ); }