TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
USB Blocker
Debapriya Saha
Nov 12
2014
Code
2.8
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
UsbBlock.zip
Imports
Microsoft.Win32
Public
Class
Form1
Private
Sub
FunctionToBlock()
Dim
regkey
As
RegistryKey
regkey = Registry.LocalMachine.OpenSubKey(
"SYSTEM\CurrentControlSet\Services\USBSTOR"
,
True
)
regkey.SetValue(
"Start"
, 4)
'4(To Disable the Ports)
End
Sub
Private
Sub
FunctionToUnblock()
Dim
rgky
As
RegistryKey
rgky = Registry.LocalMachine.OpenSubKey(
"SYSTEM\CurrentControlSet\Services\USBSTOR"
,
True
)
rgky.SetValue(
"Start"
, 3)
'3(To enable the Ports)
End
Sub
Private
Sub
btnBlock_Click(sender
As
Object
, e
As
System.EventArgs)
Handles
btnBlock.Click
FunctionToBlock()
MessageBox.Show(
"Usb Port Successfully Blocked"
)
btnUnblock.Enabled =
True
btnBlock.Enabled =
False
End
Sub
Private
Sub
btnUnblock_Click(sender
As
Object
, e
As
System.EventArgs)
Handles
btnUnblock.Click
FunctionToUnblock()
MessageBox.Show(
"Successfully Unblocked"
)
btnBlock.Enabled =
True
btnUnblock.Enabled =
False
End
Sub
Private
Sub
Form1_Load(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Load
'btnBlock.Enabled = True
'btnUnblock.Enabled = True
Dim
registryky
As
RegistryKey
Dim
var
As
Integer
registryky = Registry.LocalMachine.OpenSubKey(
"SYSTEM\CurrentControlSet\Services\USBSTOR"
,
True
)
var = registryky.GetValue(
"Start"
, 0)
If
var = 4
Then
registryky.SetValue(
"Start"
, 4)
btnBlock.Enabled =
False
btnUnblock.Enabled =
True
ElseIf
var = 3
Then
registryky.SetValue(
"Start"
, 3)
btnUnblock.Enabled =
False
btnBlock.Enabled =
True
End
If
End
Sub
Private
Sub
BtnHelp_Click(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
BtnHelp.Click
frmHelp.Show()
End
Sub
Private
Sub
btnExit_Click(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
btnExit.Click
Me
.Close()
End
Sub
End
Class
Vb.Net