Exemplo n.º 1
0
        protected override void WndProc(ref Message m)
        {
            int mess = mdisk.MessageResult(m);

            if (mess == 1)
            {
                try
                {
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }

                    if (f12 == null)
                    {
                        f12 = new Form12(strList);
                    }
                    else
                    {
                        f12.UpdateForm(strList, f12.Visible);
                    }
                }
                catch (Exception ex)
                {
                    string ss = ex.Message;
                }
            }
            if (mess == 2)
            {
                if (f12 != null)
                {
                    List <string> removelist = new List <string>(strList.ToArray());
                    strList.Clear();
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    int         i      = 0;
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                                DelStrList(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory, removelist);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    f12.Hide();
                    f12.removeUSBFile(removelist);
                    f12.UpdateForm(strList, false);
                }
            }
            base.WndProc(ref m);
        }