예제 #1
0
        public DateTime[] GetRunTimes(DateTime start, DateTime end, uint count = 0)
        {
            var pstStart = new SystemTime(start);
            var pstEnd   = new SystemTime(end);
            var zero     = IntPtr.Zero;

            if (_v2Task != null)
            {
                _v2Task.GetRunTimes(ref pstStart, ref pstEnd, ref count, ref zero);
            }
            else
            {
                var num = (count > 0 && count <= 0x5a0 ? (ushort)count : (ushort)0x5a0);
                _v1Task.GetRunTimes(ref pstStart, ref pstEnd, ref num, ref zero);
                count = num;
            }
            var timeArray = new DateTime[count];

            for (var i = 0; i < count; i++)
            {
                var ptr = new IntPtr(zero.ToInt64() + (i * Marshal.SizeOf(typeof(SystemTime))));
                timeArray[i] = (DateTime)((SystemTime)Marshal.PtrToStructure(ptr, typeof(SystemTime)));
            }
            Marshal.FreeCoTaskMem(zero);
            return(timeArray);
        }