public override void LoadDevicePartitions()
        {
            if (this.Device.HasPartition)
            {
                return;
            }
            var partlink = new DISK_INFO();
            var result   = FileServiceCoreDll.GetDiskInfo(ref partlink, this.Device.DiskNumber);

            if (result != 0)
            {
                //LogHelper.Error(string.Format(LanguageHelper.Get("LANGKEY_HuoQuCiPanFenQuXinXiShiBaiDiCe_01591"), this.Device.Name, result));
                return;
            }
            if (partlink.part_counts == 0)
            {
                //LogHelper.Info(string.Format(LanguageHelper.Get("LANGKEY_CiPanFenQuGeShuWei_01592"), this.Device.Name));
                return;
            }
            for (int i = 0; i < partlink.part_counts; i++)
            {
                var part      = partlink.pt[i];
                var partition = new FileSystemPartition();
                partition.Name         = part.driver_letter.ToString();
                partition.Discription  = part.vol_name;
                partition.FileSystem   = part.file_system;
                partition.SerialNumber = string.Format("{0:X}", part.serial_num);
                partition.Size         = (ulong)part.sectors.ToSafeInt64() * 512;
                partition.SectorOffset = (ulong)part.start_lba.ToSafeInt64();
                partition.TotalSectors = (ulong)part.sectors.ToSafeInt64();
                this.Device.Parts.Add(partition);
            }
        }
示例#2
0
        private void DoOneDeviceMonitor()
        {
            //1.获取当前连接列表
            var devices = new List <SDCardDevice>();

            var bottomdiskinfo = new DISK_INFO();

            for (byte index = 0; index < 16; index++)
            {
                var result = FileServiceCoreDll.GetDiskInfo(ref bottomdiskinfo, index);
                if (result != 0 || !bottomdiskinfo.controller.Contains("USB driver"))
                {
                    continue;
                }
                var device = new SDCardDevice();
                device.DiskNumber = bottomdiskinfo.disk_num;
                device.Name       = string.Format("Disk:{0}-{1}", index, bottomdiskinfo.sModelNumber);
                device.Size       = (ulong)bottomdiskinfo.sectors.ToSafeInt64() * 512;
                devices.Add(device);
            }

            //2.获取新增设备和断开连接设备
            var newConnecnted = devices.Except(CurConnectDevs).ToList();
            var disConnecteds = CurConnectDevs.Except(devices).ToList();

            foreach (var add in newConnecnted)
            {
                OnConnected(add);
                CurConnectDevs.Add(add);
            }

            foreach (var dis in disConnecteds)
            {
                OnDisconnected(dis);
                CurConnectDevs.Remove(dis);
            }
        }
示例#3
0
 public static extern UInt32 GetDiskInfo(ref DISK_INFO pdsk, byte dsk_num);
示例#4
0
 public void GetInfo(out DISK_INFO info)
 {
     info = new DISK_INFO();
 }
示例#5
0
 /// <summary>
 /// 获取磁盘的基本信息
 /// </summary>
 /// <param name="pdsk">磁盘信息</param>
 /// <param name="dsk_num">磁盘的编号</param>
 /// <returns>标识:0,成功</returns>
 public uint GetDiskInfoEx(ref DISK_INFO pdsk, byte dsk_num)
 {
     return(MirrorCoreDll.GetDiskInfo(ref pdsk, dsk_num));
 }