Click here to Skip to main content
12,623,027 members (28,696 online)
Click here to Skip to main content
Add your own
alternative version

Stats

19.1K views
2.4K downloads
10 bookmarked
Posted

Show and Hide Drive Using Registry in C#

, 15 Oct 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Show and hide your drive using software drive conceal

Introduction

In this tip, I will explain how to show and hide your drive using registry in C#, so we can keep/save our important and sensitive information by hiding our drive. We can hide some parts of the drive or hide the entire drive. Although it's not perfect for protecting our important and sensitive information, we can protect our important and sensitive information from people with little knowledge.

Background

Basically in this code, I will show you how to hide your drive in registry. We must create a subkey in HKEY_CURRENT_USER and this is the path Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer we must create DWORD 'NoDrives' with value 4. Value 4 is used for hiding drive 'C'.

And this is values information for hiding drive using registry:

  1. Value 4 using for hide drive = C
  2. Value 8 using for hide drive = D
  3. Value 10 using for hide drive = E
  4. Value 20 using for hide drive = F
  5. Value 40 using for hide drive = G
  6. Value 80 using for hide drive = H
  7. Value 100 using for hide drive = I
  8. Value 200 using for hide drive = J
  9. Value 400 using for hide drive = K
  10. Value 800 using for hide drive = L
  11. Value 1000 using for hide drive = M
  12. Value 2000 using for hide drive = N
  13. Value 4000 using for hide drive = O
  14. Value 8000 using for hide drive = P
  15. Value 10000 using for hide drive = Q
  16. Value 20000 using for hide drive = R
  17. Value 40000 using for hide drive = S
  18. Value 80000 using for hide drive = T
  19. Value 100000 using for hide drive = U
  20. Value 200000 using for hide drive = V
  21. Value 400000 using for hide drive = W
  22. Value 800000 using for hide drive = Y
  23. Value 1000000 using for hide drive = X
  24. Value 2000000 using for hide drive = Z
  25. Value 3ffffff used for hide = All Drive

Using the Code

Before using this code, we must import this namespace reference:

using Microsoft.Win32;
using System.Diagnostics;

This is a sample of some code to hide drive 'C' :

//button hide drive
try
{
    if (comboBox1.SelectedItem == "C")
    {
        //subkey nodrive in HKEY_CURRENT_USER
        string nodrive = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
        RegistryKey rKey1 = Registry.CurrentUser.CreateSubKey(nodrive);
        
        //create DWORD 'NoDrives' with value 4. for hiding drive C
        rKey1.SetValue("NoDrives", 
        Convert.ToInt32("4", 16), RegistryValueKind.DWord);
        rKey1.Close();
        
        //progressbarloading effect
        ploading();
        
        //give a message
        MessageBox.Show("Drive " + comboBox1.Text + 
        ":\\ successful concealed ", "Drive Conceal", 
        MessageBoxButtons.OK, MessageBoxIcon.Information);
        
        //add logs history
        listBox1.Items.Add("Drive " + comboBox1.Text + ":\\ Hidden");
        listBox1.Items.Add("On " + currentDay);
        listBox1.Items.Add("");
        
        //need restart to take effect
        restart();
    } 

You can view more code in the zip file, and the below code is the code for restart() method:

private void restart()
{
    // menghentikan process explorer
    Process p = new Process();
    foreach (System.Diagnostics.Process exe in System.Diagnostics.Process.GetProcesses())
    {
        if (exe.ProcessName == "explorer")
 
        exe.Kill();
    }
} 

Points of Interest

Hope this code will be useful for you and that you get benefited from this.
Happy programming and keep learning.

History

  • Drive conceal v.1.0

License

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

Share

About the Author

Gun Gun Febrianza
CEO Techno Camo
Indonesia Indonesia
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Questionc# Pin
sohail naseer24-Jul-14 9:41
membersohail naseer24-Jul-14 9:41 
AnswerRe: c# Pin
Gun Gun Febrianza30-Jul-14 11:26
member Gun Gun Febrianza30-Jul-14 11:26 
QuestionHide - Unhide USB drives Pin
ArchanaDamahe30-Jun-14 1:39
memberArchanaDamahe30-Jun-14 1:39 
AnswerRe: Hide - Unhide USB drives Pin
Gun Gun Febrianza30-Jul-14 11:30
member Gun Gun Febrianza30-Jul-14 11:30 
Questionstatic number of drives Pin
Master Ab25-Mar-13 12:20
memberMaster Ab25-Mar-13 12:20 
AnswerRe: static number of drives Pin
Gun Gun Febrianza30-Jul-14 11:28
member Gun Gun Febrianza30-Jul-14 11:28 
GeneralMy vote of 5 Pin
ProgramFOX24-Oct-12 7:06
memberProgramFOX24-Oct-12 7:06 
GeneralRe: My vote of 5 Pin
Gun Gun Febrianza24-Oct-12 7:09
member Gun Gun Febrianza24-Oct-12 7:09 
GeneralMy vote of 4 Pin
John Brett16-Oct-12 22:12
memberJohn Brett16-Oct-12 22:12 
GeneralRe: My vote of 4 Pin
Gun Gun Febrianza17-Oct-12 1:08
memberGun Gun Febrianza17-Oct-12 1:08 
QuestionDrive lock Pin
hazeleekaizera16-Oct-12 0:11
memberhazeleekaizera16-Oct-12 0:11 
AnswerRe: Drive lock Pin
Gun Gun Febrianza16-Oct-12 0:20
memberGun Gun Febrianza16-Oct-12 0:20 
GeneralRe: Drive lock Pin
hazeleekaizera16-Oct-12 18:03
memberhazeleekaizera16-Oct-12 18:03 
GeneralRe: Drive lock Pin
Gun Gun Febrianza16-Oct-12 18:08
memberGun Gun Febrianza16-Oct-12 18:08 
GeneralMy vote of 5 Pin
hazeleekaizera16-Oct-12 0:10
memberhazeleekaizera16-Oct-12 0:10 
GeneralRe: My vote of 5 Pin
Gun Gun Febrianza16-Oct-12 0:23
memberGun Gun Febrianza16-Oct-12 0:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161128.1 | Last Updated 16 Oct 2012
Article Copyright 2012 by Gun Gun Febrianza
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid