Example #1
0
 private void button2_Click(object sender, RoutedEventArgs e)
 {
     if (lbUSBDevices.SelectedIndex >= 0 && lbUSBDevices.SelectedIndex < USBDevices.Count)
     {
         if (USBDriver.AnyFilterInstalled(USBDevices, DriverName))
         {
             USBDriver.UninstallFilter(USBDevices[lbUSBDevices.SelectedIndex], DriverName, Native.SPDRP_LOWERFILTERS);
             USBDriver.UnistallKey(DriverName);
             USBUtils.Restart(USBDevices[lbUSBDevices.SelectedIndex]);
             button2.Content = "Install";
         }
         else
         {
             if (System.IO.File.Exists(tbLogDir.Text + lbUSBDevices.Items[lbUSBDevices.SelectedIndex].ToString() + @".log"))
             {
                 System.IO.File.Delete(tbLogDir.Text + lbUSBDevices.Items[lbUSBDevices.SelectedIndex].ToString() + @".log");
             }
             USBDriver.InstallKey(@"..\..\..\Driver\objchk_wxp_x86\i386\" + DriverName + ".sys");
             USBDriver.InstallFilter(USBDevices[lbUSBDevices.SelectedIndex], DriverName, Native.SPDRP_LOWERFILTERS,
                                     10000000, tbLogDir.Text + lbUSBDevices.Items[lbUSBDevices.SelectedIndex].ToString() + @".log");
             USBUtils.Restart(USBDevices[lbUSBDevices.SelectedIndex]);
             button2.Content = "Remove";
         }
     }
 }
Example #2
0
 private void lbUSBDevices_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lbUSBDevices.SelectedIndex >= 0 && lbUSBDevices.SelectedIndex < USBDevices.Count)
     {
         if (USBDriver.IsFilterKeyInstalled(USBDevices[lbUSBDevices.SelectedIndex], DriverName))
         {
             button2.Content = "Remove";
         }
         else
         {
             button2.Content = "Install";
         }
     }
 }