Click here to Skip to main content
15,887,939 members
Please Sign up or sign in to vote.
2.09/5 (4 votes)
See more:
I want to create program to lock USB with a password and everything in it is hidden and scrambled unless a user entered a right password to unlock it. I have searched a lot but I just found this software USB Locker. Can anyone guide me how this gonna programmed. Is it written using WMI or some windows registry values.

Update:
I need to make a USB drive password protected while it is used in any system and it should run inside the USB drive and that scrambled the size and all information of the USB, after running this program again in another system, the program request for a password and open all data after giving it right password.
Posted
Updated 29-Sep-15 23:11pm
v3

One problem you're going to run into is that any C# app requires the .NET Framework to be installed on the machine before you can run the app. If the framework is not installed your code doesn't run.

The only way you're going to "protect" the contents of the drive with a password is if all the files were stored into a .ZIP file on the USB drive or something similar.
 
Share this answer
 
Comments
Shahzad Mirza 30-Sep-15 5:09am    
There is a software in market named USB Locker is working according to my requirements. If its difficult to be compatible in every computer using .NET then how this program can be possible?
Dave Kreskowiak 30-Sep-15 9:07am    
You can NOT write it in managed code, meaning C#, VB.NET, or any other language that targets the .NET Framework. That means it has to be written in C/C++. The runtimes for that are already part of Windows.
Take a look at this CodeProject: Developing a USB Storage Device Protection Tool with C#, it seems to be a good starting point.

To disable USB storage devices it uses a registry key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor":

C#
void USB_disableAllStorageDevices()
{
    RegistryKey key =
        Registry.LocalMachine.OpenSubKey
           ("SYSTEM\\CurrentControlSet\\Services\\UsbStor",true);
    if (key != null)
    {
       key.SetValue("Start", 4, RegistryValueKind.DWord);
    }
    key.Close();
}
 
Share this answer
 
v2
Comments
Shahzad Mirza 29-Sep-15 11:14am    
I already read that article and it is really informative for windows and registry point of view. But I need to make a USB drive password protected while it is used in any system and it should run inside the USB drive and that scrambled the size and all information of the USB, after running this program again in another system, the program request for a password and open all data after giving it right password.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900