

'====================================================================
' Registry tutorial - How to make your computer more secure by hiding
' drives of your choice.
' 
' This program will show / hide drives from another user, whilst your
' user account will NOT be effected.
'====================================================================

'====================================================================================
' Should you have any problems restoring (seeing) a drive and this 
' program will not work for you, then you can always use regedit.exe
'
' You will need to click on "HKEY_USERS", then "File", "Load Hive" and select
' the correct NTUSER.DAT file i.e. C:|Users\Andy\NTUSER.DAT
'
' and go to...
'
' HKEY_USERS\\UserName\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer
'
' Set the NoDrives entry to zero, or just delete it - then restart your computer.
'==================================================================================== 

'=====================================================================
' USE:
'
' Select a user, then a drive to hide it, then click Apply.
'
' Repeat the process to show the drive again.
'
'=====================================================================

'=================================================
' 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"

declare "kernel32",GetDriveTypeFL alias GetDriveTypeA(dir:string),int
declare "kernel32",GetLogicalDrivesFL alias GetLogicalDrives(),int

'====================================================================
' 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
const BUTTON_3 = 53

const STATIC_1 = 60

WINDOW win,win2

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

string Drive,dir
int i,l,result,Selected

string SubKeyHive[100]
string UsersHive[100]
string UsersName[100]
string UsersPath[100]
int ActUsers

Def name as string 
Def filesystemname as string
int flags,serialnumber,maxcomponentlength ' Integers of the call
flags=0:serialnumber=0:maxcomponentlength=0 ' Make sure there all set to zero

'===========================================================
' First we will get a list of user accounts on this machine.
'===========================================================

EnumUserAccounts()

'================================================================
' Now we will open a window so you can choose which user you want
' to change the registry setting for.
'================================================================

OPENWINDOW win2,100,100,390,495,@CAPTION|@MINBOX|@MAXBOX|@TOPMOST,0," User accounts on this machine.",&Win2Hnd	
CONTROL win2,@LISTBOX,"",10,20,360,295,@CTLISTNOTIFY|@HSCROLL,100	
CONTROL win2,@STATIC,"Select a user and change their settings...",28,350,300,25,0,STATIC_1
CONTROL win2,@BUTTON,"Next >",28,400,100,25,0,BUTTON_1

for x = 0 to ActUsers-1
    addstring(win2,100,UsersName[x+1])
next x 

SETFONT win2,"Arial",12,500,0,100
SETFONT win2,"Arial",12,500,0,BUTTON_1
SETFONT win2,"Arial",12,500,0,STATIC_1

SETCONTROLCOLOR win2,STATIC_1,RGB(0,0,0),rgb(255,255,255)

setselected(win2,100,1)
setfocus win2
waituntil win2 = 0

'===============================================================================
' 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.
'===============================================================================


'*******************************************************
' NOTICE - HKEY_CURRENT_USER\\Software....
'
' is now replaced by:
'
' "HKEY_USERS\\" + UsersName[Selected] + "\\Software...
'
' Example - HKEY_USERS\\Andy\Software...
'*******************************************************

DriveCount = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\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_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "A"))
DriveB = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "B"))
DriveC = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "C"))
DriveD = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "D"))
DriveE = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "E"))
DriveF = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "F"))
DriveG = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "G"))
DriveH = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "H"))
DriveI = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "I"))
DriveJ = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "J"))
DriveK = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "K"))
DriveL = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "L"))
DriveM = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "M"))
DriveN = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "N"))
DriveO = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "O"))
DriveP = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "P"))
DriveQ = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "Q"))
DriveR = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "R"))
DriveS = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "S"))
DriveT = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "T"))
DriveU = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "U"))
DriveV = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "V"))
DriveW = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "W"))
DriveX = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "X"))
DriveY = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "Y"))
DriveZ = val(RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", "Z"))

GetDriveNames() 'Get the drive label name if available and store it.

ALabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","A")
BLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","B")
CLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","C")
DLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","D")
ELabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","E")
FLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","F")
GLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","G")
HLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","H")
ILabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","I")
JLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","J")
KLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","K")
LLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","L")
MLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","M")
NLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","N")
OLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","O")
PLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","P")
QLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","Q")
RLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","R")
SLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","S")
TLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","T")
ULabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","U")
VLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","V")
WLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","W")
XLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","X")
YLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","Y")
ZLabel = RegGetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","Z")

'===============================
' Open a window and let's begin.
'===============================

OpenWindow win,0,0,900,590,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU,0,"Hide / Show drives for " + UsersName[Selected],&win_handler
'Left hand side of screen
CONTROL win,@CHECKBOX,"Hide Drive (A) "+ALabel,29,76,345,25,0, Check1
CONTROL win,@CHECKBOX,"Hide Drive (B) "+BLabel,29,108,345,25,0,Check2
CONTROL win,@CHECKBOX,"Hide Drive (C) "+Clabel,29,140,345,25,0,Check3
CONTROL win,@CHECKBOX,"Hide Drive (D) "+DLabel,29,172,345,25,0,Check4
CONTROL win,@CHECKBOX,"Hide Drive (E) "+ELabel,29,205,345,25,0,Check5
CONTROL win,@CHECKBOX,"Hide Drive (F) "+FLabel,29,236,345,25,0,Check6
CONTROL win,@CHECKBOX,"Hide Drive (G) "+GLabel,29,268,345,25,0,Check7
CONTROL win,@CHECKBOX,"Hide Drive (H) "+HLabel,29,298,345,25,0,Check8
CONTROL win,@CHECKBOX,"Hide Drive (I) "+ILabel,29,329,345,25,0,Check9
CONTROL win,@CHECKBOX,"Hide Drive (J) "+JLabel,29,358,345,25,0,Check10
CONTROL win,@CHECKBOX,"Hide Drive (K) "+KLabel,29,388,345,25,0,Check11
CONTROL win,@CHECKBOX,"Hide Drive (L) "+LLAbel,28,417,345,25,0,Check12
CONTROL win,@CHECKBOX,"Hide Drive (M) "+MLabel,29,446,345,25,0,Check13

'Right hand side of the screen
CONTROL win,@CHECKBOX,"Hide Drive (N) "+NLabel,450,76,345,25,0, Check14
CONTROL win,@CHECKBOX,"Hide Drive (O) "+OLabel,450,108,345,25,0,Check15
CONTROL win,@CHECKBOX,"Hide Drive (P) "+PLabel,450,140,344,25,0,Check16
CONTROL win,@CHECKBOX,"Hide Drive (Q) "+QLabel,450,172,346,25,0,Check17
CONTROL win,@CHECKBOX,"Hide Drive (R) "+RLabel,450,205,347,25,0,Check18
CONTROL win,@CHECKBOX,"Hide Drive (S) "+SLabel,450,236,347,25,0,Check19
CONTROL win,@CHECKBOX,"Hide Drive (T) "+TLabel,450,268,348,25,0,Check20
CONTROL win,@CHECKBOX,"Hide Drive (U) "+ULabel,450,298,347,25,0,Check21
CONTROL win,@CHECKBOX,"Hide Drive (V) "+VLabel,450,329,347,25,0,Check22
CONTROL win,@CHECKBOX,"Hide Drive (W) "+WLabel,450,358,346,25,0,Check23
CONTROL win,@CHECKBOX,"Hide Drive (X) "+XLabel,450,388,347,25,0,Check24
CONTROL win,@CHECKBOX,"Hide Drive (Y) "+YLabel,450,417,348,25,0,Check25
CONTROL win,@CHECKBOX,"Hide Drive (Z) "+ZLabel,450,446,348,25,0,Check26

CONTROL win,@BUTTON,"Apply",28,500,100,25,0,BUTTON_1
CONTROL win,@BUTTON,"Show All Drives",450,500,260,25,0,BUTTON_2
CONTROL win,@BUTTON,"Quit",790,500,80,25,0,BUTTON_3

if DriveA = 1
   setcontroltext(win,Check3,"Show Drive (A) "+ALabel)
endif

if DriveB = 1
   setcontroltext(win,Check3,"Show Drive (B) "+BLabel)
endif

if DriveC = 1
   setcontroltext(win,Check3,"Show Drive (C) "+CLabel)
endif

if DriveD = 1
   setcontroltext(win,Check4,"Show Drive (D) "+DLabel)
endif

if DriveE = 1
   setcontroltext(win,Check5,"Show Drive (E) "+ELabel)
endif

if DriveF = 1
   setcontroltext(win,Check6,"Show Drive (F) "+FLabel)
endif

if DriveG = 1
   setcontroltext(win,Check7,"Show Drive (G) "+GLabel)
endif

if DriveH = 1
   setcontroltext(win,Check8,"Show Drive (H) "+HLabel)
endif

if DriveI = 1
   setcontroltext(win,Check9,"Show Drive (I) "+ILabel)
endif

if DriveJ = 1
   setcontroltext(win,Check10,"Show Drive (J) "+JLabel)
endif

if DriveK = 1
   setcontroltext(win,Check11,"Show Drive (K) "+KLabel)
endif

if DriveL = 1
   setcontroltext(win,Check12,"Show Drive (L) "+LLabel)
endif

if DriveM = 1
   setcontroltext(win,Check13,"Show Drive (M) "+MLabel)
endif

if DriveN = 1
   setcontroltext(win,Check14,"Show Drive (N) "+NLabel)
endif

if DriveO = 1
   setcontroltext(win,Check15,"Show Drive (O) "+OLabel)
endif

if DriveP = 1
   setcontroltext(win,Check16,"Show Drive (P) "+PLabel)
endif

if DriveQ = 1
   setcontroltext(win,Check17,"Show Drive (Q) "+QLabel)
endif

if DriveR = 1
   setcontroltext(win,Check18,"Show Drive (R) "+RLabel)
endif

if DriveS = 1
   setcontroltext(win,Check19,"Show Drive (S) "+SLabel)
endif

if DriveT = 1
   setcontroltext(win,Check20,"Show Drive (T) "+TLabel)
endif

if DriveU = 1
   setcontroltext(win,Check21,"Show Drive (U) "+ULabel)
endif

if DriveV = 1
   setcontroltext(win,Check22,"Show Drive (V) "+VLabel)
endif

if DriveW = 1
   setcontroltext(win,Check23,"Show Drive (W) "+WLabel)
endif

if DriveX = 1
   setcontroltext(win,Check24,"Show Drive (X) "+XLabel)
endif

if DriveY = 1
   setcontroltext(win,Check25,"Show Drive (Y) "+YLabel)
endif

if DriveZ = 1
   setcontroltext(win,Check26,"Show Drive (Z) "+ZLabel)
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
SETFONT win,"Arial",12,500,0,BUTTON_3

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_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "A")
									DriveCount += 1
                           setcontroltext(win,Check1,"Show Drive (A) "+ALabel)
                           DriveA = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "A")
									DriveCount = DriveCount - 1
                           setcontroltext(win,Check1,"Hide Drive (A) "+ALabel)
                           DriveA = 0
                        endif 
                        setstate(win,Check1,0)
							endif  

							if getstate(win,Check2) = 1 'B
                        if DriveB = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "B")
									DriveCount += 2
                           setcontroltext(win,Check2,"Show Drive (B) " +BLabel)
                           DriveB = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "B")
									DriveCount = DriveCount - 2
                           setcontroltext(win,Check2,"Hide Drive (B) " +BLabel)
                           DriveB = 0
                        endif 
                        setstate(win,Check2,0)
							endif

							if getstate(win,Check3) = 1 'C
                        if DriveC = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "C")
									DriveCount += 4
                           setcontroltext(win,Check3,"Show Drive (C) " +CLabel)
                           DriveC = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "C")
									DriveCount = DriveCount - 4
                           setcontroltext(win,Check3,"Hide Drive (C) " +CLabel)
                           DriveC = 0
                        endif 
                        setstate(win,Check3,0)
							endif

							if getstate(win,Check4) = 1 'D
                        if DriveD = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "D")
									DriveCount += 8
                           setcontroltext(win,Check4,"Show Drive (D) " +DLabel)
                           DriveD = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "D")
									DriveCount = DriveCount - 8
                           setcontroltext(win,Check4,"Hide Drive (D) " +DLabel)
                           DriveD = 0
                        endif 
                        setstate(win,Check4,0)
							endif

							if getstate(win,Check5) = 1 'E
                        if DriveE = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "E")
									DriveCount += 16
                           setcontroltext(win,Check5,"Show Drive (E) " +ELabel)
                           DriveE = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "E")
									DriveCount = DriveCount - 16
                           setcontroltext(win,Check5,"Hide Drive (E) " +ELabel)
                           DriveE = 0
                        endif 
                        setstate(win,Check5,0)
							endif

							if getstate(win,Check6) = 1 'F
                        if DriveF = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "F")
									DriveCount += 32
                           setcontroltext(win,Check6,"Show Drive (F) " +FLabel)
                           DriveF = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "F")
									DriveCount = DriveCount - 32
                           setcontroltext(win,Check6,"Hide Drive (F) " +FLabel)
                           DriveF = 0
                        endif 
                        setstate(win,Check6,0)
							endif

							if getstate(win,Check7) = 1 'G
                        if DriveG = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "G")
									DriveCount += 64
                           setcontroltext(win,Check7,"Show Drive (G) " +GLabel)
                           DriveG = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "G")
									DriveCount = DriveCount - 64
                           setcontroltext(win,Check7,"Hide Drive (G) " +GLabel)
                           DriveG = 0
                        endif 
                        setstate(win,Check7,0)
							endif

							if getstate(win,Check8) = 1 'H
                        if DriveH = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "H")
									DriveCount += 128
                           setcontroltext(win,Check8,"Show Drive (H) " +HLabel)
                           DriveH = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "H")
									DriveCount = DriveCount - 128
                           setcontroltext(win,Check8,"Hide Drive (H) " +HLabel)
                           DriveH = 0
                        endif 
                        setstate(win,Check8,0)
							endif

							if getstate(win,Check9) = 1 'I
                        if DriveI = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "I")
									DriveCount += 256
                           setcontroltext(win,Check9,"Show Drive (I) " +ILabel)
                           DriveI = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "I")
									DriveCount = DriveCount - 256
                           setcontroltext(win,Check9,"Hide Drive (I) " +ILabel)
                           DriveI = 0
                        endif 
                        setstate(win,Check9,0)
							endif

							if getstate(win,Check10) = 1 'J
                        if DriveJ = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "J")
									DriveCount += 512
                           setcontroltext(win,Check10,"Show Drive (J) " +JLabel)
                           DriveJ = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "J")
									DriveCount = DriveCount - 512
                           setcontroltext(win,Check10,"Hide Drive (J) " +JLabel)
                           DriveJ = 0
                        endif 
                        setstate(win,Check10,0)
							endif

							if getstate(win,Check11) = 1 'K
                        if DriveK = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "K")
									DriveCount += 1024
                           setcontroltext(win,Check11,"Show Drive (K) " +KLabel)
                           DriveK = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "K")
									DriveCount = DriveCount - 1024
                           setcontroltext(win,Check11,"Hide Drive (K) " +KLabel)
                           DriveK = 0
                        endif 
                        setstate(win,Check11,0)
							endif

							if getstate(win,Check12) = 1 'L
                        if DriveL = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "L")
									DriveCount += 2048
                           setcontroltext(win,Check12,"Show Drive (L) " +LLabel)
                           DriveL = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "L")
									DriveCount = DriveCount - 2048
                           setcontroltext(win,Check12,"Hide Drive (L) " +LLabel)
                           DriveL = 0
                        endif 
                        setstate(win,Check12,0)
							endif

							if getstate(win,Check13) = 1 'M
                        if DriveM = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "M")
									DriveCount += 4096
                           setcontroltext(win,Check13,"Show Drive (M) " +MLabel)
                           DriveM = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "M")
									DriveCount = DriveCount - 4096
                           setcontroltext(win,Check13,"Hide Drive (M) " +MLabel)
                           DriveM = 0
                        endif 
                        setstate(win,Check13,0)
							endif

							if getstate(win,Check14) = 1 'N
                        if DriveN = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "N")
									DriveCount += 8192
                           setcontroltext(win,Check14,"Show Drive (N) " +NLabel)
                           DriveN = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "N")
									DriveCount = DriveCount - 8192
                           setcontroltext(win,Check14,"Hide Drive (N) " +NLabel)
                           DriveN = 0
                        endif 
                        setstate(win,Check14,0)
							endif

							if getstate(win,Check15) = 1 'O
                        if DriveO = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "O")
									DriveCount += 16384
                           setcontroltext(win,Check15,"Show Drive (O) " +OLabel)
                           DriveM = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "O")
									DriveCount = DriveCount - 16384
                           setcontroltext(win,Check15,"Hide Drive (O) " +OLabel)
                           DriveO = 0
                        endif 
                        setstate(win,Check15,0)
							endif

							if getstate(win,Check16) = 1 'P
                        if DriveP = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "P")
									DriveCount += 32768
                           setcontroltext(win,Check16,"Show Drive (P) " +PLabel)
                           DriveP = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "P")
									DriveCount = DriveCount - 32768
                           setcontroltext(win,Check16,"Hide Drive (P) " +PLabel)
                           DriveP = 0
                        endif 
                        setstate(win,Check16,0)
							endif

							if getstate(win,Check17) = 1 'Q
                        if DriveQ = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "Q")
									DriveCount += 65536
                           setcontroltext(win,Check17,"Show Drive (Q) " +QLabel)
                           DriveQ = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "Q")
									DriveCount = DriveCount - 65536
                           setcontroltext(win,Check17,"Hide Drive (Q) " +QLabel)
                           DriveQ = 0
                        endif 
                        setstate(win,Check17,0)
							endif

							if getstate(win,Check18) = 1 'R
                        if DriveR = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "R")
									DriveCount += 131072
                           setcontroltext(win,Check18,"Show Drive (R) " +RLabel)
                           DriveR = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "R")
									DriveCount = DriveCount - 131072
                           setcontroltext(win,Check18,"Hide Drive (R) " +RLabel)
                           DriveR = 0
                        endif 
                        setstate(win,Check18,0)
							endif

							if getstate(win,Check19) = 1 'S
                        if DriveS = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "S")
									DriveCount += 262144
                           setcontroltext(win,Check19,"Show Drive (S) " +SLabel)
                           DriveS = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "S")
									DriveCount = DriveCount - 262144
                           setcontroltext(win,Check19,"Hide Drive (S) " +SLabel)
                           DriveS = 0
                        endif 
                        setstate(win,Check19,0)
							endif

							if getstate(win,Check20) = 1 'T
                        if DriveT = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "T")
									DriveCount += 524288
                           setcontroltext(win,Check20,"Show Drive (T) " +TLabel)
                           DriveT = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "T")
									DriveCount = DriveCount - 524288
                           setcontroltext(win,Check20,"Hide Drive (T) " +TLabel)
                           DriveT = 0
                        endif 
                        setstate(win,Check20,0)
							endif

							if getstate(win,Check21) = 1 'U
                        if DriveU = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "U")
									DriveCount += 1048576
                           setcontroltext(win,Check21,"Show Drive (U) " +ULabel)
                           DriveU = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "U")
									DriveCount = DriveCount - 1048576
                           setcontroltext(win,Check21,"Hide Drive (U) " +ULabel)
                           DriveU = 0
                        endif 
                        setstate(win,Check21,0)
							endif

							if getstate(win,Check22) = 1 'V
                        if DriveV = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "V")
									DriveCount +=  2097152
                           setcontroltext(win,Check22,"Show Drive (V) " +VLabel)
                           DriveV = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "V")
									DriveCount = DriveCount -  2097152
                           setcontroltext(win,Check22,"Hide Drive (V) " +VLabel)
                           DriveV = 0
                        endif 
                        setstate(win,Check22,0)
							endif

							if getstate(win,Check23) = 1 'W
                        if DriveW = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "W")
									DriveCount += 4194304
                           setcontroltext(win,Check23,"Show Drive (W) " +WLabel)
                           DriveW = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "W")
									DriveCount = DriveCount - 4194304
                           setcontroltext(win,Check23,"Hide Drive (W) " +WLabel)
                           DriveW = 0
                        endif 
                        setstate(win,Check23,0)
							endif

							if getstate(win,Check24) = 1 'X
                        if DriveX = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "X")
									DriveCount +=  8388608
                           setcontroltext(win,Check24,"Show Drive (X) " +XLabel)
                           DriveX = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "X")
									DriveCount = DriveCount -  8388608
                           setcontroltext(win,Check24,"Hide Drive (X) " +XLabel)
                           DriveX = 0
                        endif 
                        setstate(win,Check24,0)
							endif

							if getstate(win,Check25) = 1 'Y
                        if DriveY = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "Y")
									DriveCount += 16777216
                           setcontroltext(win,Check25,"Show Drive (Y) " +YLabel)
                           DriveY = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "Y")
									DriveCount = DriveCount - 16777216
                           setcontroltext(win,Check25,"Hide Drive (Y) " +YLabel)
                           DriveY = 0
                        endif 
                        setstate(win,Check25,0)
							endif

							if getstate(win,Check26) = 1 'Z
                        if DriveZ = 0  
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 1, "Z")
									DriveCount += 33554432
                           setcontroltext(win,Check26,"Show Drive (Z) " +ZLabel)
                           DriveZ = 1
                        else
									result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "Z")
									DriveCount = DriveCount - 33554432
                           setcontroltext(win,Check26,"Hide Drive (Z) " +ZLabel)
                           DriveZ = 0
                        endif 
                        setstate(win,Check26,0)
							endif

                     '=====================================
                     ' Now we will store the NoDrive count.
                     '=====================================

                     result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", DriveCount, "NoDrives")

                     '==========================================================
                     ' Since this is a user account that is NOT LOGGED ON, we 
                     ' do not need to re-start explorer.exe any more.
                     ' The changes will be applied when they next log on.
                     '==========================================================

							'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_USERS\\" + UsersName[Selected] + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", 0, "NoDrives")

								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "A")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "B")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "C")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "D")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "E")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "F")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "G")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "H")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "I")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "J")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "K")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "L")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "M")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "N")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "O")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "P")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "Q")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "R")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "S")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "T")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "U")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "V")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "W")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "X")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "Y")
								result = RegSetDWValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives", 0, "Z")
                       
                        setcontroltext(win,Check1, "Hide Drive (A) " +ALAbel)
                        setcontroltext(win,Check2, "Hide Drive (B) " +BLAbel)
                        setcontroltext(win,Check3, "Hide Drive (C) " +CLAbel)
                        setcontroltext(win,Check4, "Hide Drive (D) " +DLAbel)
                        setcontroltext(win,Check5, "Hide Drive (E) " +ELAbel)
                        setcontroltext(win,Check6, "Hide Drive (F) " +FLAbel)
                        setcontroltext(win,Check7, "Hide Drive (G) " +GLAbel)
                        setcontroltext(win,Check8, "Hide Drive (H) " +HLAbel)
                        setcontroltext(win,Check9, "Hide Drive (I) " +ILAbel)
                        setcontroltext(win,Check10,"Hide Drive (J) " +JLAbel)
                        setcontroltext(win,Check11,"Hide Drive (K) " +KLAbel)
                        setcontroltext(win,Check12,"Hide Drive (L) " +LLAbel)
                        setcontroltext(win,Check13,"Hide Drive (M) " +MLAbel)
                        setcontroltext(win,Check14,"Hide Drive (N) " +NLAbel)
                        setcontroltext(win,Check15,"Hide Drive (O) " +OLAbel)
                        setcontroltext(win,Check16,"Hide Drive (P) " +PLAbel)
                        setcontroltext(win,Check17,"Hide Drive (Q) " +QLAbel)
                        setcontroltext(win,Check18,"Hide Drive (R) " +RLAbel)
                        setcontroltext(win,Check19,"Hide Drive (S) " +SLAbel)
                        setcontroltext(win,Check20,"Hide Drive (T) " +TLAbel)
                        setcontroltext(win,Check21,"Hide Drive (U) " +ULAbel)
                        setcontroltext(win,Check22,"Hide Drive (V) " +VLAbel)
                        setcontroltext(win,Check23,"Hide Drive (W) " +WLAbel)
                        setcontroltext(win,Check24,"Hide Drive (X) " +XLAbel)
                        setcontroltext(win,Check25,"Hide Drive (Y) " +YLAbel)
                        setcontroltext(win,Check26,"Hide Drive (Z) " +ZLAbel)

                        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....
								'ENDIF
							 endif

						ENDIF

					CASE BUTTON_3 'Quit
							IF @NOTIFYCODE = 0
                        UnloadUser()
                        closewindow win
                        end
                     endif
			ENDSELECT

		CASE @IDCLOSEWINDOW
           UnloadUser()
			  CLOSEWINDOW win
           end
	ENDSELECT
	RETURN 0
ENDSUB

SUB Win2Hnd(), INT
	SELECT @MESSAGE
		CASE @IDCREATE
			CENTERWINDOW win2
			/* Initialize any controls here */
		CASE @IDCONTROL
			SELECT @CONTROLID

				CASE BUTTON_1 'Next
						IF @NOTIFYCODE = 0
							Selected  = getselected(win2,100) + 1

                     ' HKEY_CURRENT_USER\\Volatile Environment, USERNAME - tells us the current user account name

                     if UsersName[Selected] <> ltrim$(RegGetValue("HKEY_CURRENT_USER\\Volatile Environment","USERNAME"))
								LoadUser()
								closewindow win2
                     endif
                  endif 

					CASE BUTTON_3 'Quit
							IF @NOTIFYCODE = 0
                        end
                     endif
			ENDSELECT

		CASE @IDCLOSEWINDOW
			  CLOSEWINDOW win2
           end 
	ENDSELECT
	RETURN 0
ENDSUB

sub SetPrivilege(HANDLE hToken, string lpszPrivilege,INT bEnablePrivilege) 

	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
sub GetDriveNames()

Drive = GetAllDrivesStr()

l = len(Drive)
for i = 1 to l
	dir = mid$(Drive,i,1)
   int DriveType = 0
   DriveType = GetDriveTypeFL(dir + ":\\")
	'print dir , " ",Drivetype 
   string strdrive = ""
   strdrive = dir + ":\\"
   name = ""

	if((strdrive <> "A:\\") & (strdrive <> "B:\\"))
		GetVolumeInformationA(strdrive,name,255,serialnumber,maxcomponentlength,flags,filesystemname,255)
	endif

   if DriveType = 2 and strdrive = "A:\\" or strdrive = "B:\\" 
      result = RegSetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","Floppy Drive",dir)
      goto nexti
   endif

   if DriveType = 5 then 
      result = RegSetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","CD / DVD Drive",dir)
      goto nexti
   endif

	if((strdrive <> "A:\\") & (strdrive <> "B:\\"))
		if len(name) = 0 and DriveType = 3
         result = RegSetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels","Fixed Drive",dir)
		else
         result = RegSetValue("HKEY_USERS\\" + UsersName[Selected] + "\\Software\\Andys Hidden Drives\\Labels",name,dir)
		endif
   endif

label nexti
next i

return
endsub

' GetAllDrivesStr
sub GetAllDrivesStr(),string
def n, t, s:int
def d:string
	d = ""
	n = GetLogicalDrivesFL()
	for t=0 to 25
		s = 2 ^ t
		if (n & s)
			d += chr$(65 + t)
		endif
	next t
return d
EndSub

sub EnumUserAccounts()
examkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList"

'Count the number of sub keys
ret = RegCountSubKeys(examkey)

'Enumerate sub keys
FOR y = 0 to (ret-1)
	retval = RegEnumKey(examkey,y)
   SubKeyHive[y] = retval
NEXT y

for x = 0 to ret-1

   examkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\" + SubKeyHive[x]  
	values = RegCountEntries(examkey)

	'Enumerate the entry names
	FOR y = 0 to (values-1)
		retval = RegEnumEntryName(examkey,y)

		if retval = "ProfileImagePath" and instr(examkey,"S-1-5-21")
			resultin = RegGetValue(examkey,retval)

         int z

         z = instr(examkey,"S-1-5-21")      

         ActUsers ++
         UsersHive[ActUsers] = mid$(examkey,z,len(examkey))
         UsersName[ActUsers] = mid$(resultin,10,len(resultin))
         UsersPath[ActUsers] = resultin + "\\ntuser.dat"
		endif
	NEXT y

next x

return
endsub

sub LoadUser()

HANDLE hToken
TOKEN_PRIVILEGES tp[2] ' make space for two LUID_AND_ATTRIBUTES

if (0=OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
	_MessageBox(0, "OpenProcessToken failed")
else
	if (0=(LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid) _
	and LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &tp.Privileges[1].Luid)))
		_MessageBox(0, "LookupPrivilegeValue failed")
	else
		tp.PrivilegeCount = 2
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED
		tp.Privileges[1].Attributes = SE_PRIVILEGE_ENABLED
		if (0=AdjustTokenPrivileges(hToken,FALSE,&tp,0,NULL,NULL))
			_MessageBox(0, "AdjustTokenPrivileges failed")
		endif
	endif
	CloseHandle(hToken)
endif

LONG errorcode 
errorcode = RegLoadKey(0x80000003, UsersName[Selected] , UsersPath[Selected])
if (errorcode)
	_MessageBox(0, "Sorry, could not load " + UsersName[Selected] + "'s settings, try restarting your computer and try again.")
endif

return
endsub

sub UnloadUser()
HANDLE hToken
TOKEN_PRIVILEGES tp[2] ' make space for two LUID_AND_ATTRIBUTES

if (0=OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
	_MessageBox(0, "OpenProcessToken failed")
else
	if (0=(LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid) _
	and LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &tp.Privileges[1].Luid)))
		_MessageBox(0, "LookupPrivilegeValue failed")
	else
		tp.PrivilegeCount = 2
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED
		tp.Privileges[1].Attributes = SE_PRIVILEGE_ENABLED
		if (0=AdjustTokenPrivileges(hToken,FALSE,&tp,0,NULL,NULL))
			_MessageBox(0, "AdjustTokenPrivileges failed")
		endif
	endif
	CloseHandle(hToken)
endif

RegUnLoadKey(0x80000003, UsersName[Selected])
return
endsub


