USB Port Programming in C | Enable or disable USB ports

USB Port Programming in C | Enable or disable USB ports

447
14
SHARE

Hey friends, today we are going to discuss things about in C. In this tutorial, i am going to show you how to enable or disable USB Ports in windows. By blocking the usb port we can control whether user to access the machine or not. Many schools, colleges, offices have no USB drive rules i.e. USB ports are blocked. This trick(C program) will help us to open the blocked usb ports.

USB Port Programming in C | Enable or disable USB ports

This is small and easy code, once the block usb program executed the computer will not recognize any inserted usb drive, but we can reverse it by unblocking the usb port. This program tested on XP and Windows 7 . You can try this program on your own computer, as I have given the unblock code also.

How the Logic of USB port programming in C works ?

USB port programming in C is itself a cool phenomenon. The logic of the USB programs is quite simple. The ‘C’ source file block_usb.c writes the DWORD value of 4 (100 in binary) in the registry settings at “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start” to ‘lock’ the USB ports.

Similarly, in the inverse process, the ‘C’ source file Unblock_usb.c writes the DWORD value of 3 (011 in binary) in the registry settings at “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start” to ‘unlock’ the USB ports.

C Code to disable USB ports :

#include<stdio.h>
void main()
{
system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 4 \/f");
}

Save this code as block_usb.c and open it with turbo , after compilation it will create a block_usb.exe which is a simple program that will disable (block) all USB ports of the computer.

 

C Program to Enable USB ports :

#include<stdio.h>
void main()
{
system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 3 \/f");
}

Save this code as unblock_usb.c and compile it with turbo c to get the unblock_usb.exe  and Execute the unblock_usb.exe and now the computer detecting your pen drive.

We hope you all have enjoyed the USB port Programming in . If you have any queries or doubts ask us in form of comments.

 

14 COMMENTS

  1. Hi Lokesh,

    I am web designer and I tried this program on windows 7 Home Basic 64 bit. It shows an alert that this program is not compatible with the version of windows you are running …

  2. It’s a pity you don’t have a donate button! I’d without a doubt donate to this fantastic blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to new updates and will share this blog with my Facebook group. Talk soon!

  3. Wow, marvelous blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is excellent, as well as the content!. Thanks For Your article about USB Port Programming in C | Enable or disable USB ports .

  4. Wow, fantastic blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is fantastic, as well as the content!. Thanks For Your article about USB Port Programming in C | Enable or disable USB ports .

LEAVE A REPLY