private DongleInfo[] GetDongleInfo(int count) { List <DongleInfo> keyInfo = new List <DongleInfo>(); IntPtr ptr = IntPtr.Zero; try { int size = IntPtrUtil.SizeOf(typeof(DONGLE_INFO)); ptr = IntPtrUtil.Create(size * (int)count); long __count; this.lastErrorCode = Dongle_Enum(ptr, out __count); //__count is indeed count of dongle for (int i = 0; i < __count; i++) { IntPtr __ptr = IntPtrUtil.Create(ptr, i * size); DONGLE_INFO devInfo = IntPtrUtil.ToStru <DONGLE_INFO>(__ptr); keyInfo.Add(ParseDongleInfo((short)i, devInfo)); } } catch (Exception ex) { logger.Error(ex.Message); return(null); } finally { IntPtrUtil.Free(ref ptr); } return(keyInfo.ToArray()); }
private DongleInfo ParseDongleInfo(short seq, DONGLE_INFO devInfo) { DongleInfo dongleInfo = new DongleInfo() { Seq = seq, Version = String.Format("v{0}.{1:d2}", devInfo.m_Ver >> 8 & 0xff, devInfo.m_Ver & 0xff), //BitConverter.ToString(devInfo.m_BirthDay)), UserId = devInfo.m_UserID.ToString("X08"), AppId = devInfo.m_PID.ToString("X08"), KeyId = BitConverter.ToString(devInfo.m_HID), Description = GetDongleModel((byte)(devInfo.m_Type & 0x0ff)) }; logger.Debug(dongleInfo.GetInfo()); return(dongleInfo); }