public CoreVersion GetVersion(CoreDll.VersionType versionType) { try { sbyte[] versionB = new sbyte[VERSION_SIZE]; IntPtr[] sizeB = new IntPtr[1]; sizeB[0] = new IntPtr(VERSION_SIZE); GCHandle versionH = GCHandle.Alloc(versionB, GCHandleType.Pinned); GCHandle sizeH = GCHandle.Alloc(sizeB, GCHandleType.Pinned); try { IntPtr versionP = versionH.AddrOfPinnedObject(); IntPtr sizeP = sizeH.AddrOfPinnedObject(); if (m_dll.adVersionGet(versionType, versionP, sizeP) == CoreDll.Error.Ok) { return(new CoreVersion(versionB)); } } finally { versionH.Free(); sizeH.Free(); } } catch (Exception) { } return(null); }
public CoreVersion GetVersion(CoreDll.VersionType versionType) { sbyte[] version = new sbyte[VERSION_SIZE]; IntPtr[] pVersionSize = new IntPtr[1]; pVersionSize[0] = new IntPtr(VERSION_SIZE); if (m_dll.adVersionGet(versionType, Marshal.UnsafeAddrOfPinnedArrayElement(version, 0), Marshal.UnsafeAddrOfPinnedArrayElement(pVersionSize, 0)) == CoreDll.Error.Ok) { return(new CoreVersion(version)); } return(null); }