Using C# Program you can control usb ports in system . if you want to disable All ports of your system you can use the following program for the this task.
Example 1 :
Above is a snapshot of application Developed in C# for enabling and disabling Usb ports of a system.
you can develop your own Program like this just do as directed following
Getting start :
first create your project in Visual Studio and name it what ever you want now Design your form and start coding as following:
Example 1 :
you can develop your own Program like this just do as directed following
Getting start :
first create your project in Visual Studio and name it what ever you want now Design your form and start coding as following:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace UsbProgram
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void lockbtn_Click(object sender, EventArgs e)
{
// Create and name your button on form as lockbtn
try
{
string path = "SYSTEM\\CurrentControlSet\\services\\USBSTOR\\";
RegistryKey RK = Registry.LocalMachine.OpenSubKey(path, true);
RK.SetValue("Start", "4", RegistryValueKind.DWord);
status.Text = "Status : All Usb Ports Locked !";
}
catch (Exception ex)
{
MessageBox.Show(" Should be Run as Adminstrator","Stop");
}
}
private void unlockbtn_Click(object sender, EventArgs e)
{
//Name your unlock button as unlockbtn
status.Text = "Status : All Usb Ports Unlocked !";
string path = "SYSTEM\\CurrentControlSet\\services\\USBSTOR\\";
RegistryKey RK = Registry.LocalMachine.OpenSubKey(path, true);
RK.SetValue("Start", "3", RegistryValueKind.DWord);
}
}
}

No comments:
Post a Comment