//this code is use to create a program to enable and disable Mass storage without disabling USB (you can use usb mouse after disabling the mass storage )
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace USBGame
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnenable_Click(object sender, EventArgs e)
{
const string keyName = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR";
// int tLong = (int )Registry.GetValue(keyName, "Start",0);
Registry.SetValue(keyName, "Start", "00000003");
MessageBox.Show("USB MassStorage Enabled");
}
private void btndisable_Click(object sender, EventArgs e)
{
const string keyName = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR";
// int tLong = (int )Registry.GetValue(keyName, "Start",0);
Registry.SetValue(keyName, "Start", "00000004");
MessageBox.Show("USB MassStorage Disabled");
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
MessageBox.Show("Developed By Rajesh Kumar Rolen");
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("It will disable your all USB ports and you will not able to use any USB Mass Storage or Mouse or Keyboard", "Disable USB Completely", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
const string keyName = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR";
// int tLong = (int )Registry.GetValue(keyName, "Start",0);
Registry.SetValue(keyName, "Start", "00000005");
MessageBox.Show("USB Disabled Completely");
}
else
{
MessageBox.Show("Abbe Baaaaach Gaya Nahe to KeyBoard and Mouse dono he band ho jate");
}
}
}
}
Enable & Disable Mass( pen drive) Storage through C#.net
Posted by
Rajesh Rolen
at
Tuesday, April 28, 2009
Labels: C#.NET
2 comments:
many thanks.you are genius.
the disable works fine please tell me how to enable it. bcz your code is not working.
Post a Comment