Esempio n. 1
0
        /// <summary>
        /// Load the usb devices that are already connected to the system
        /// </summary>
        private void LoadConnectedDevices()
        {
            try
            {
                DriveInfo[] driveInfos = DriveInfo.GetDrives();
                foreach (var driveInfo in driveInfos)
                {
                    //check if the drive is a usb drive
                    USB.USBDevice device = USB.FindDriveLetter(driveInfo.Name.Substring(0, 2));
                    if (device != null)
                    {
                        if (driveInfo.IsReady && driveInfo.TotalSize > 0)
                        {
                            serial = DriveInformation.getSerial(driveInfo.Name); //USB.FindDriveLetter(driveInfo.Name.Substring(0, 2)).SerialNumber;

                            //RegisterDevice(serial);
                            loadDevice(driveInfo.Name);
                        }
                    }
                }
                statuslabel.Text = "Ready";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 2
0
 // Token: 0x06000739 RID: 1849 RVA: 0x0002A750 File Offset: 0x00028950
 private void ProcessHub(USB.USBHub hub)
 {
     foreach (USB.USBPort current in hub.GetPorts())
     {
         if (current.IsHub)
         {
             this.ProcessHub(current.GetHub());
         }
         USB.USBDevice device = current.GetDevice();
         if (device != null && device.DeviceManufacturer != null && device.DeviceManufacturer.ToLower() == "dpdev" && device.DeviceProduct != null && device.DeviceProduct.ToLower() == "gamegenie")
         {
             this.m_serial = device.SerialNumber;
         }
     }
 }
Esempio n. 3
0
        public Form2()
        {
            InitializeComponent();

            //create event handler for the detection of the usb devices
            driveDetector = new DriveDetector();
            driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived);
            driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved);
            selectedDrive      = null;
            toolStrip1.Visible = false;
            this.Load         += (s, a) => {
                //Load the settings file of the project
                if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SmartSync")))
                {
                    Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SmartSync"));
                }
                listView1.AllowDrop = true;

                //Load the system directories in a treeview

                treeView1.Nodes.Clear();
                DriveInfo[] ds = DriveInfo.GetDrives();

                foreach (DriveInfo d in ds)
                {
                    USB.USBDevice device = USB.FindDriveLetter(d.Name.Substring(0, 2));
                    if (device == null)
                    {
                        if (d.IsReady && d.TotalSize > 0 && IsNotReadOnly(d.ToString()))
                        {
                            //populate the list view with the directories in the drives of the system

                            TreeNode parentNode = new TreeNode();
                            parentNode.ImageIndex         = 0;
                            parentNode.SelectedImageIndex = 0;
                            parentNode.Text = d.RootDirectory.ToString();
                            //string[] dir = getDirectories(di.RootDirectory.ToString());
                            treeView1.Nodes.Add(parentNode);

                            foreach (var si in d.RootDirectory.GetDirectories())
                            {
                                if ((si.Attributes & FileAttributes.System) == FileAttributes.System)
                                {
                                    continue;
                                }
                                TreeNode child = new TreeNode();
                                child.ImageIndex         = 0;
                                child.Name               = si.FullName.ToString();
                                child.SelectedImageIndex = 0;

                                child.Text = si.Name;
                                parentNode.Nodes.Add(child);
                            }
                            parentNode.Expand();
                        }
                    }
                }

                //listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

                drives = FileDetailsMgmt.getRegisteredDrives();


                statuslabel.Text = "Loading Application settings...";
                Application.DoEvents();

                statuslabel.Text = "Loading USB drives...";

                //Load the usb devices that are connected to the system
                LoadConnectedDevices();

                MenuItem item = new MenuItem();
                item.Text   = "Open";
                item.Click += (b, y) => { Show(); };

                MenuItem item1 = new MenuItem();
                item1.Text   = "Exit";
                item1.Click += (t, y) => { Application.ExitThread(); };
                ContextMenu contextMenu = new ContextMenu();
                contextMenu.MenuItems.AddRange(new MenuItem[] { item, item1 });
                notifyIcon1.ContextMenu = contextMenu;
            };
        }