

'====================================================================
' Registry tutorial - How to make your computer more secure by hiding
' drives of your choice.
' 
' This program will show / hide drives from you - the current user.
'====================================================================

'====================================================================================
' Should you have any problems restoring (seeing) a drive and this 
' program will not work for you, then you can always use regedit.exe
' and go to...
'
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer
'
' Set the NoDrives entry to zero, or just delete it - then restart your computer.
'==================================================================================== 

'=====================================================================
' USE:
'
' Select a drive to hide it, then click Apply.
' Wait for your desktop / taskbar to restart and check explorer for 
' the drive.
'
' Repeat the process to see the drive again.
'
' I WOULD SUGGEST THAT YOU DO NOT HIDE YOUR SYSTEM (C) DRIVE.
'
'=====================================================================

'=================================================
' Compile as single file and run as Administrator!
'=================================================

$ifdef WIN32
$define WIN32_LEAN_AND_MEAN
$endif
 
$define __winreg_inc__ 'Always use this with Registry.inc if you have windowssdk.inc included.
$include "windowssdk.inc"
$include "Registry.inc"
$include "Psapi.inc"
$include "TlHelp32.inc"

'====================================================================
' This first section of code is used to make sure we have full access 
' to the registry.
'====================================================================

DWORD aProcesses[1024], cbNeeded, cProcesses, procId, bProcess[512] 
handle hProcess, hTokenSelf, hProcSelf

hProcSelf = OpenProcess( PROCESS_ALL_ACCESS,FALSE,GetCurrentProcessId() )
OpenProcessToken(hProcSelf,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY ,&hTokenSelf)

SetPrivilege(hTokenSelf,"SeDebugPrivilege",true)

'========================
' Now some constants etc.
'========================

const Check1  = 1 
const Check2  = 2
const Check3  = 3
const Check4  = 4
const Check5  = 5
const Check6  = 6
const Check7  = 7
const Check8  = 8
const Check9  = 9
const Check10 = 10
const Check11 = 11
const Check12 = 12
const Check13 = 13
const Check14 = 14
const Check15 = 15
const Check16 = 16
const Check17 = 17
const Check18 = 18
const Check19 = 19
const Check20 = 20
const Check21 = 21
const Check22 = 22
const Check23 = 23
const Check24 = 24
const Check25 = 25
const Check26 = 26

const BUTTON_1 = 51
const BUTTON_2 = 52

WINDOW win

int x = 0
int DriveCount = 0
int DriveA,DriveB,DriveC,DriveD,DriveE,DriveF,DriveG,DriveH,DriveI,DriveJ,DriveK,DriveL,DriveM
int DriveN,DriveO,DriveP,DriveQ,DriveR,DriveS,DriveT,DriveU,DriveV,DriveW,DriveX,DriveY,DriveZ


'===============================================================================
' Here we get the value of the registry entry 'NoDrives'.
' Since this entry does not normally ship with Windows, it's unlikely to be on
' your machine, and so the first time you run this program the value will be 
' zero.
'
' However, once you start hiding drives it will have some value stored in it.
'===============================================================================

DriveCount = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives"))


'============================================================================
' Here I will store a 1 or 0 for each drive that is hidden (1) or showing (0)
' I found this much easier than trying to calculate it.
'============================================================================

DriveA = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "A"))
DriveB = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "B"))
DriveC = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "C"))
DriveD = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "D"))
DriveE = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "E"))
DriveF = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "F"))
DriveG = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "G"))
DriveH = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "H"))
DriveI = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "I"))
DriveJ = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "J"))
DriveK = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "K"))
DriveL = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "L"))
DriveM = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "M"))
DriveN = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "N"))
DriveO = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "O"))
DriveP = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "P"))
DriveQ = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "Q"))
DriveR = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "R"))
DriveS = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "S"))
DriveT = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "T"))
DriveU = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "U"))
DriveV = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "V"))
DriveW = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "W"))
DriveX = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "X"))
DriveY = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "Y"))
DriveZ = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "Z"))


'===============================
' Open a window and let's begin.
'===============================

OpenWindow win,0,0,565,619,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU,0,"Hide / Show drives.",&win_handler
'Left hand side of screen
CONTROL win,@CHECKBOX,"Hide Drive A",29,76,146,25,0, Check1
CONTROL win,@CHECKBOX,"Hide Drive B",29,108,145,25,0,Check2
CONTROL win,@CHECKBOX,"Hide Drive C",29,140,144,25,0,Check3
CONTROL win,@CHECKBOX,"Hide Drive D",29,172,146,25,0,Check4
CONTROL win,@CHECKBOX,"Hide Drive E",29,205,147,25,0,Check5
CONTROL win,@CHECKBOX,"Hide Drive F",29,236,147,25,0,Check6
CONTROL win,@CHECKBOX,"Hide Drive G",29,268,148,25,0,Check7
CONTROL win,@CHECKBOX,"Hide Drive H",29,298,147,25,0,Check8
CONTROL win,@CHECKBOX,"Hide Drive I",29,329,147,25,0,Check9
CONTROL win,@CHECKBOX,"Hide Drive J",29,358,146,25,0,Check10
CONTROL win,@CHECKBOX,"Hide Drive K",29,388,147,25,0,Check11
CONTROL win,@CHECKBOX,"Hide Drive L",28,417,148,25,0,Check12
CONTROL win,@CHECKBOX,"Hide Drive M",29,446,146,25,0,Check13

'Right hand side of the screen
CONTROL win,@CHECKBOX,"Hide Drive N",250,76,145,25,0, Check14
CONTROL win,@CHECKBOX,"Hide Drive O",250,108,145,25,0,Check15
CONTROL win,@CHECKBOX,"Hide Drive P",250,140,144,25,0,Check16
CONTROL win,@CHECKBOX,"Hide Drive Q",250,172,146,25,0,Check17
CONTROL win,@CHECKBOX,"Hide Drive R",250,205,147,25,0,Check18
CONTROL win,@CHECKBOX,"Hide Drive S",250,236,147,25,0,Check19
CONTROL win,@CHECKBOX,"Hide Drive T",250,268,148,25,0,Check20
CONTROL win,@CHECKBOX,"Hide Drive U",250,298,147,25,0,Check21
CONTROL win,@CHECKBOX,"Hide Drive V",250,329,147,25,0,Check22
CONTROL win,@CHECKBOX,"Hide Drive W",250,358,146,25,0,Check23
CONTROL win,@CHECKBOX,"Hide Drive X",250,388,147,25,0,Check24
CONTROL win,@CHECKBOX,"Hide Drive Y",250,417,148,25,0,Check25
CONTROL win,@CHECKBOX,"Hide Drive Z",250,446,148,25,0,Check26

CONTROL win,@BUTTON,"Apply",28,500,100,25,0,BUTTON_1
CONTROL win,@BUTTON,"Show All Drives",250,500,260,25,0,BUTTON_2

if DriveA = 1
   setcontroltext(win,Check3,"Show Drive A")
endif

if DriveB = 1
   setcontroltext(win,Check3,"Show Drive B")
endif

if DriveC = 1
   setcontroltext(win,Check3,"Show Drive C")
endif

if DriveD = 1
   setcontroltext(win,Check4,"Show Drive D")
endif

if DriveE = 1
   setcontroltext(win,Check5,"Show Drive E")
endif

if DriveF = 1
   setcontroltext(win,Check6,"Show Drive F")
endif

if DriveG = 1
   setcontroltext(win,Check7,"Show Drive G")
endif

if DriveH = 1
   setcontroltext(win,Check8,"Show Drive H")
endif

if DriveI = 1
   setcontroltext(win,Check9,"Show Drive I")
endif

if DriveJ = 1
   setcontroltext(win,Check10,"Show Drive J")
endif

if DriveK = 1
   setcontroltext(win,Check11,"Show Drive K")
endif

if DriveL = 1
   setcontroltext(win,Check12,"Show Drive L")
endif

if DriveM = 1
   setcontroltext(win,Check13,"Show Drive M")
endif

if DriveN = 1
   setcontroltext(win,Check14,"Show Drive N")
endif

if DriveO = 1
   setcontroltext(win,Check15,"Show Drive O")
endif

if DriveP = 1
   setcontroltext(win,Check16,"Show Drive P")
endif

if DriveQ = 1
   setcontroltext(win,Check17,"Show Drive Q")
endif

if DriveR = 1
   setcontroltext(win,Check18,"Show Drive R")
endif

if DriveS = 1
   setcontroltext(win,Check19,"Show Drive S")
endif

if DriveT = 1
   setcontroltext(win,Check20,"Show Drive T")
endif

if DriveU = 1
   setcontroltext(win,Check21,"Show Drive U")
endif

if DriveV = 1
   setcontroltext(win,Check22,"Show Drive V")
endif

if DriveW = 1
   setcontroltext(win,Check23,"Show Drive W")
endif

if DriveX = 1
   setcontroltext(win,Check24,"Show Drive X")
endif

if DriveY = 1
   setcontroltext(win,Check25,"Show Drive Y")
endif

if DriveZ = 1
   setcontroltext(win,Check26,"Show Drive Z")
endif

for x = 1 to 26
    SETFONT win,"Arial",12,500,0,x
    SETCONTROLCOLOR win,x,RGB(0,0,0),rgb(255,255,255)
next x

SETFONT win,"Arial",12,500,0,BUTTON_1
SETFONT win,"Arial",12,500,0,BUTTON_2

WAITUNTIL ISWINDOWCLOSED(win)
END

SUB win_handler(), INT
	SELECT @MESSAGE
		CASE @IDCREATE
			CENTERWINDOW win
			/* Initialize any controls here */
		CASE @IDCONTROL
			SELECT @CONTROLID

				CASE BUTTON_1 'Apply

                 '====================================================================
                 ' When the Apply button is clicked, we will check to see which drives
                 ' have been selected.
                 '
                 ' If the drive is visable, then we will add it's corresponding drive
                 ' number to the NoDrives registry entry.
                 ' i.e. If drive A is selected, we will add 1 to the NoDrives count
                 ' we would add 2 for drive B, 4 for drive C and so on...
                 '
                 ' If the drive selected is hidden, then we will subtract it's number
                 ' from NoDrives.
                 '====================================================================  

						IF @NOTIFYCODE = 0
							if getstate(win,Check1) = 1 'A
                        if DriveA = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "A")
									DriveCount += 1
                           setcontroltext(win,Check1,"Show Drive A")
                           DriveA = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "A")
									DriveCount = DriveCount - 1
                           setcontroltext(win,Check1,"Hide Drive A")
                           DriveA = 0
                        endif 
                        setstate(win,Check1,0)
							endif  

							if getstate(win,Check2) = 1 'B
                        if DriveB = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "B")
									DriveCount += 2
                           setcontroltext(win,Check2,"Show Drive B")
                           DriveB = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "B")
									DriveCount = DriveCount - 2
                           setcontroltext(win,Check2,"Hide Drive B")
                           DriveB = 0
                        endif 
                        setstate(win,Check2,0)
							endif

							if getstate(win,Check3) = 1 'C
                        if DriveC = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "C")
									DriveCount += 4
                           setcontroltext(win,Check3,"Show Drive C")
                           DriveC = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "C")
									DriveCount = DriveCount - 4
                           setcontroltext(win,Check3,"Hide Drive C")
                           DriveC = 0
                        endif 
                        setstate(win,Check3,0)
							endif

							if getstate(win,Check4) = 1 'D
                        if DriveD = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "D")
									DriveCount += 8
                           setcontroltext(win,Check4,"Show Drive D")
                           DriveD = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "D")
									DriveCount = DriveCount - 8
                           setcontroltext(win,Check4,"Hide Drive D")
                           DriveD = 0
                        endif 
                        setstate(win,Check4,0)
							endif

							if getstate(win,Check5) = 1 'E
                        if DriveE = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "E")
									DriveCount += 16
                           setcontroltext(win,Check5,"Show Drive E")
                           DriveE = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "E")
									DriveCount = DriveCount - 16
                           setcontroltext(win,Check5,"Hide Drive E")
                           DriveE = 0
                        endif 
                        setstate(win,Check5,0)
							endif

							if getstate(win,Check6) = 1 'F
                        if DriveF = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "F")
									DriveCount += 32
                           setcontroltext(win,Check6,"Show Drive F")
                           DriveF = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "F")
									DriveCount = DriveCount - 32
                           setcontroltext(win,Check6,"Hide Drive F")
                           DriveF = 0
                        endif 
                        setstate(win,Check6,0)
							endif

							if getstate(win,Check7) = 1 'G
                        if DriveG = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "G")
									DriveCount += 64
                           setcontroltext(win,Check7,"Show Drive G")
                           DriveG = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "G")
									DriveCount = DriveCount - 64
                           setcontroltext(win,Check7,"Hide Drive G")
                           DriveG = 0
                        endif 
                        setstate(win,Check7,0)
							endif

							if getstate(win,Check8) = 1 'H
                        if DriveH = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "H")
									DriveCount += 128
                           setcontroltext(win,Check8,"Show Drive H")
                           DriveH = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "H")
									DriveCount = DriveCount - 128
                           setcontroltext(win,Check8,"Hide Drive H")
                           DriveH = 0
                        endif 
                        setstate(win,Check8,0)
							endif

							if getstate(win,Check9) = 1 'I
                        if DriveI = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "I")
									DriveCount += 256
                           setcontroltext(win,Check9,"Show Drive I")
                           DriveI = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "I")
									DriveCount = DriveCount - 256
                           setcontroltext(win,Check9,"Hide Drive I")
                           DriveI = 0
                        endif 
                        setstate(win,Check9,0)
							endif

							if getstate(win,Check10) = 1 'J
                        if DriveJ = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "J")
									DriveCount += 512
                           setcontroltext(win,Check10,"Show Drive J")
                           DriveJ = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "J")
									DriveCount = DriveCount - 512
                           setcontroltext(win,Check10,"Hide Drive J")
                           DriveJ = 0
                        endif 
                        setstate(win,Check10,0)
							endif

							if getstate(win,Check11) = 1 'K
                        if DriveK = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "K")
									DriveCount += 1024
                           setcontroltext(win,Check11,"Show Drive K")
                           DriveK = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "K")
									DriveCount = DriveCount - 1024
                           setcontroltext(win,Check11,"Hide Drive K")
                           DriveK = 0
                        endif 
                        setstate(win,Check11,0)
							endif

							if getstate(win,Check12) = 1 'L
                        if DriveL = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "L")
									DriveCount += 2048
                           setcontroltext(win,Check12,"Show Drive L")
                           DriveL = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "L")
									DriveCount = DriveCount - 2048
                           setcontroltext(win,Check12,"Hide Drive L")
                           DriveL = 0
                        endif 
                        setstate(win,Check12,0)
							endif

							if getstate(win,Check13) = 1 'M
                        if DriveM = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "M")
									DriveCount += 4096
                           setcontroltext(win,Check13,"Show Drive M")
                           DriveM = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "M")
									DriveCount = DriveCount - 4096
                           setcontroltext(win,Check13,"Hide Drive M")
                           DriveM = 0
                        endif 
                        setstate(win,Check13,0)
							endif

							if getstate(win,Check14) = 1 'N
                        if DriveN = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "N")
									DriveCount += 8192
                           setcontroltext(win,Check14,"Show Drive N")
                           DriveN = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "N")
									DriveCount = DriveCount - 8192
                           setcontroltext(win,Check14,"Hide Drive N")
                           DriveN = 0
                        endif 
                        setstate(win,Check14,0)
							endif

							if getstate(win,Check15) = 1 'O
                        if DriveO = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "O")
									DriveCount += 16384
                           setcontroltext(win,Check15,"Show Drive O")
                           DriveM = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "O")
									DriveCount = DriveCount - 16384
                           setcontroltext(win,Check15,"Hide Drive O")
                           DriveO = 0
                        endif 
                        setstate(win,Check15,0)
							endif

							if getstate(win,Check16) = 1 'P
                        if DriveP = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "P")
									DriveCount += 32768
                           setcontroltext(win,Check16,"Show Drive P")
                           DriveP = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "P")
									DriveCount = DriveCount - 32768
                           setcontroltext(win,Check16,"Hide Drive P")
                           DriveP = 0
                        endif 
                        setstate(win,Check16,0)
							endif

							if getstate(win,Check17) = 1 'Q
                        if DriveQ = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "Q")
									DriveCount += 65536
                           setcontroltext(win,Check17,"Show Drive Q")
                           DriveQ = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Q")
									DriveCount = DriveCount - 65536
                           setcontroltext(win,Check17,"Hide Drive Q")
                           DriveQ = 0
                        endif 
                        setstate(win,Check17,0)
							endif

							if getstate(win,Check18) = 1 'R
                        if DriveR = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "R")
									DriveCount += 131072
                           setcontroltext(win,Check18,"Show Drive R")
                           DriveR = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "R")
									DriveCount = DriveCount - 131072
                           setcontroltext(win,Check18,"Hide Drive R")
                           DriveR = 0
                        endif 
                        setstate(win,Check18,0)
							endif

							if getstate(win,Check19) = 1 'S
                        if DriveS = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "S")
									DriveCount += 262144
                           setcontroltext(win,Check19,"Show Drive S")
                           DriveS = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "S")
									DriveCount = DriveCount - 262144
                           setcontroltext(win,Check19,"Hide Drive S")
                           DriveS = 0
                        endif 
                        setstate(win,Check19,0)
							endif

							if getstate(win,Check20) = 1 'T
                        if DriveT = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "T")
									DriveCount += 524288
                           setcontroltext(win,Check20,"Show Drive T")
                           DriveT = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "T")
									DriveCount = DriveCount - 524288
                           setcontroltext(win,Check20,"Hide Drive T")
                           DriveT = 0
                        endif 
                        setstate(win,Check20,0)
							endif

							if getstate(win,Check21) = 1 'U
                        if DriveU = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "U")
									DriveCount += 1048576
                           setcontroltext(win,Check21,"Show Drive U")
                           DriveU = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "U")
									DriveCount = DriveCount - 1048576
                           setcontroltext(win,Check21,"Hide Drive U")
                           DriveU = 0
                        endif 
                        setstate(win,Check21,0)
							endif

							if getstate(win,Check22) = 1 'V
                        if DriveV = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "V")
									DriveCount +=  2097152
                           setcontroltext(win,Check22,"Show Drive V")
                           DriveV = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "V")
									DriveCount = DriveCount -  2097152
                           setcontroltext(win,Check22,"Hide Drive V")
                           DriveV = 0
                        endif 
                        setstate(win,Check22,0)
							endif

							if getstate(win,Check23) = 1 'W
                        if DriveW = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "W")
									DriveCount += 4194304
                           setcontroltext(win,Check23,"Show Drive W")
                           DriveW = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "W")
									DriveCount = DriveCount - 4194304
                           setcontroltext(win,Check23,"Hide Drive W")
                           DriveW = 0
                        endif 
                        setstate(win,Check23,0)
							endif

							if getstate(win,Check24) = 1 'X
                        if DriveX = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "X")
									DriveCount +=  8388608
                           setcontroltext(win,Check24,"Show Drive X")
                           DriveX = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "X")
									DriveCount = DriveCount -  8388608
                           setcontroltext(win,Check24,"Hide Drive X")
                           DriveX = 0
                        endif 
                        setstate(win,Check24,0)
							endif

							if getstate(win,Check25) = 1 'Y
                        if DriveY = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "Y")
									DriveCount += 16777216
                           setcontroltext(win,Check25,"Show Drive Y")
                           DriveY = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Y")
									DriveCount = DriveCount - 16777216
                           setcontroltext(win,Check25,"Hide Drive Y")
                           DriveY = 0
                        endif 
                        setstate(win,Check25,0)
							endif

							if getstate(win,Check26) = 1 'Z
                        if DriveZ = 0  
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "Z")
									DriveCount += 33554432
                           setcontroltext(win,Check26,"Show Drive Z")
                           DriveZ = 1
                        else
									result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Z")
									DriveCount = DriveCount - 33554432
                           setcontroltext(win,Check26,"Hide Drive Z")
                           DriveZ = 0
                        endif 
                        setstate(win,Check26,0)
							endif

                     '=====================================
                     ' Now we will store the NoDrive count.
                     '=====================================

                     result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", DriveCount, "NoDrives")

                     '==========================================================
                     ' Here we will stop explorer.exe, which closes the desktop,
                     ' Windows should re-start it in a second or two for you.
                     ' 
                     ' If not, use Task Manager (new task) to run it again or 
                     ' failing that, restart your computer.
                     '==========================================================

							retval = findPIDByName("explorer.exe")

							if retval <>0
								killProcess(retval) 'Here KillProcess stops an exe OR use GOSUB DOSOMETHINGELSE etc....
							ELSE
								'print "Process Not Found."
							ENDIF

					CASE BUTTON_2 'Show all drives
							IF @NOTIFYCODE = 0

                        DriveCount = 0

                        DriveA = 0 
                        DriveB = 0 
                        DriveC = 0 
                        DriveD = 0 
                        DriveE = 0 
                        DriveF = 0 
                        DriveG = 0 
                        DriveH = 0 
                        DriveI = 0 
                        DriveJ = 0 
                        DriveK = 0
                        DriveL = 0  

								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", 0, "NoDrives")

								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "A")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "B")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "C")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "D")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "E")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "F")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "G")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "H")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "I")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "J")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "K")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "L")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "M")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "N")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "O")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "P")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Q")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "R")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "S")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "T")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "U")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "V")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "W")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "X")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Y")
								result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Z")
                       
                        setcontroltext(win,Check1, "Hide Drive A")
                        setcontroltext(win,Check2, "Hide Drive B")
                        setcontroltext(win,Check3, "Hide Drive C")
                        setcontroltext(win,Check4, "Hide Drive D")
                        setcontroltext(win,Check5, "Hide Drive E")
                        setcontroltext(win,Check6, "Hide Drive F")
                        setcontroltext(win,Check7, "Hide Drive G")
                        setcontroltext(win,Check8, "Hide Drive H")
                        setcontroltext(win,Check9, "Hide Drive I")
                        setcontroltext(win,Check10,"Hide Drive J")
                        setcontroltext(win,Check11,"Hide Drive K")
                        setcontroltext(win,Check12,"Hide Drive L")
                        setcontroltext(win,Check13,"Hide Drive M")
                        setcontroltext(win,Check14,"Hide Drive N")
                        setcontroltext(win,Check15,"Hide Drive O")
                        setcontroltext(win,Check16,"Hide Drive P")
                        setcontroltext(win,Check17,"Hide Drive Q")
                        setcontroltext(win,Check18,"Hide Drive R")
                        setcontroltext(win,Check19,"Hide Drive S")
                        setcontroltext(win,Check20,"Hide Drive T")
                        setcontroltext(win,Check21,"Hide Drive U")
                        setcontroltext(win,Check22,"Hide Drive V")
                        setcontroltext(win,Check23,"Hide Drive W")
                        setcontroltext(win,Check24,"Hide Drive X")
                        setcontroltext(win,Check25,"Hide Drive Y")
                        setcontroltext(win,Check26,"Hide Drive Z")

                        for x = 1 to 26
                            setstate(win,x,0)
                        next x

								retval = findPIDByName("explorer.exe")

								if retval <>0
									killProcess(retval) 'Here KillProcess stops an exe OR use GOSUB DOSOMETHINGELSE etc....
								ELSE
									'print "Process Not Found."
								ENDIF
							 endif

						ENDIF

			ENDSELECT

		CASE @IDCLOSEWINDOW
			CLOSEWINDOW win
	ENDSELECT
	RETURN 0
ENDSUB

'======================================================
' This code is used for finding and stopping a program.
'======================================================

sub findPIDByName(string fileNameToFindPID),int
'// required by fined PIDByName
const TH32CS_SNAPHEAPLIST	=0x00000001
const TH32CS_SNAPPROCESS	=0x00000002
const TH32CS_SNAPTHREAD		=0x00000004
const TH32CS_SNAPMODULE		=0x00000008
const TH32CS_SNAPMODULE32	=0x00000010
const TH32CS_SNAPALL		=(TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE)
const TH32CS_INHERIT		=0x80000000
const PROCESS_ALL_ACCESS	=0x1F0FFF


type PROCESSENTRY32
	uint dwSize
	uint cntUsage
	uint th32ProcessID
	uint th32DefaultHeapID
	uint th32ModuleID
	uint cntThreads
	uint th32ParentProcessID
	uint pcPriClassBase
	uint dwFlags
	istring szExeFile[259]
endtype

def pe:PROCESSENTRY32
string item,PID
DEF retval, x:int 
x = 0


hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)
pe.dwSize=len(pe)
retval=Process32First(hSnapshot,pe)

do

if LCASE$(pe.szExeFile) = LCASE$(fileNameToFindPID)
	CloseHandle(hSnapshot)
	return pe.th32ProcessID
ENDIF
item = pe.szExeFile
PID = STR$(pe.th32ProcessID)

print "["+pid+"] "+item

x++

	dwPriorityClass = 0
 
   hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe.th32ProcessID)

    if hProcess = NULL
      print error("Open Process Fail findpidbyname ")
    else
    
      dwPriorityClass = GetPriorityClass(hProcess)

      if dwPriorityClass <>0
			'print dwPriorityClass 
		ELSE
			'print error("dwPriorityClass")
		endif
	CloseHandle(hProcess)

/*' Print process Info
    print "process ID        = ",pe.th32ProcessID
    print "thread count      = ",pe.cntThreads
    print "parent process ID = ",pe.th32ParentProcessID
    print "Priority Base     = ",pe.pcPriClassBase
	print "Priority Class    = ",dwPriorityClass
 */ 
endif

	pe.dwSize=len(PROCESSENTRY32)
	retval=Process32Next(hSnapshot,pe)

until retval = false

CloseHandle(hSnapshot)
return 0
ENDSUB

sub findProcessIdByName(int processID),INT

int ret 
string szProcessName

szProcessName = SPACE$(255)

hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE,processID )

	if hProcess <>0
		
		ret = EnumProcessModules( hProcess, bProcess[0], len(bProcess), &cbNeeded)
 
			if ret <>0
				ret = GetModuleBaseName(hProcess, bProcess[0], szProcessName,len(szProcessName))
'				ret = GetModuleFileNameEx(hProcess, bProcess[0], szProcessName,len(szProcessName))

	
					if ret <>0
						print szProcessName
					ELSE
						print error("GetModule")
					ENDIF

			ELSE
				error("EnumProcessModules")
			ENDIF
		CloseHandle( hProcess )
	ELSE
		print error( "Openprocess Failed"+str$(processID))
	ENDIF
 return 0
ENDSUB

sub killProcess(int PID)

HANDLE hProc

hProc = OpenProcess(PROCESS_ALL_ACCESS|PROCESS_TERMINATE, FALSE, PID)

          if hProc <>0

               if TerminateProcess(hProc, 0) <>0
                    'MessageBox (NULL, "CLOSED", "CLOSED", @MB_ICONSTOP) 
               else 
                    MessageBox (NULL, error("SUB KillProcess "), "NOT CLOSED PID"+str$(procId), @MB_ICONSTOP) 
                  CloseHandle(hProc)
			   endif
          else 
               MessageBox (NULL, error("SUB KillProcess "),"I CANT CLOSE "+str$(procId),@MB_ICONSTOP) 
		  ENDIF
ENDSUB


sub SetPrivilege(HANDLE hToken, string lpszPrivilege,INT bEnablePrivilege) 

'TYPE TOKEN_PRIVILEGES
	'DEF PrivilegeCount:INT
	'DEF LowPart:INT
	'DEF HighPart:INT
	'DEF Attributes:INT
'ENDTYPE


	def tp:TOKEN_PRIVILEGES
	def luid:LUID

	if LookupPrivilegeValue(NULL,lpszPrivilege,&luid ) = 0
		error("LookupPrivilegeValue error: ")
		return FALSE
	ENDIF

	tp.PrivilegeCount = 1
	tp.Privileges[0].Luid = luid
	
    if bEnablePrivilege = true
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED
	else
		tp.Privileges[0].Attributes = 0
	ENDIF

	'// Enable the privilege or disable all privileges.

	if AdjustTokenPrivileges(hToken,FALSE, &tp, LEN(TOKEN_PRIVILEGES), 0, 0) =0
			error("AdjustTokenPrivileges error:") 
		  return FALSE 
	ENDIF 

	if GetLastError() = ERROR_NOT_ALL_ASSIGNED

		  print "The token does not have the specified privilege."
		  return FALSE
	ENDIF

	return TRUE

ENDSUB

SUB error(string errorCall),string  

   INT CodeErrorId, nBufferSize, flag 
   STRING sBuffer,retError  

   nBufferSize = 1024 
   sBuffer = String$(nBufferSize, Chr$(0)) 
   flag=FORMAT_MESSAGE_FROM_SYSTEM 

   CodeErrorId=GetLastError() 

   FormatMessage(flag, NULL,CodeErrorId,LANG_NEUTRAL, sBuffer, nBufferSize ,NULL ) 
	retError = errorCall+" / "+sBuffer+" / ErrorID = "+str$(CodeErrorID)

return retError

endsub
