Mega Code Archive

 
Categories / Delphi / System
 

Hiding driver(s) in My Computer

Title: Hiding driver(s) in My Computer Question: How can I hide driver icons in "My Computer"? Answer: Here is a tip on how to hide drivers in "My Computer". I hope this be usefull for someone. To do this, you can use the following procedure and then please restart windows. The "NoDrives" value included a 32 bit word and you can write as decimal numbers. A driver's value is twice value than preceding driver value. These are A = 1 , B = 2 , C = 4 , D = 8 , E = 16 ....and others. For example; if you want to hide drive C and drive E, then you would add 4 and 16. Result; 4 + 16 = 20 and Called like so ; HideDriver(20); uses Registry; procedure HideDriver(HideNumber: integer); var Reg: TRegistry; begin Reg := TRegistry.Create; try with Reg do begin RootKey := HKEY_CURRENT_USER; OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', True); WriteInteger('NoDrives', HideNumber); CloseKey; RootKey := HKEY_LOCAL_MACHINE; OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', True); WriteInteger('NoDrives', HideNumber); CloseKey; end; finally Reg.Free; end; end; To visible drivers in "My Computer" then adding this code to the OnClick event of the button and then please restart windows. var Reg: TRegistry; begin Reg := TRegistry.Create; try with Reg do begin RootKey := HKEY_CURRENT_USER; OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', True); DeleteValue('NoDrives'); CloseKey; RootKey := HKEY_LOCAL_MACHINE; OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', True); DeleteValue('NoDrives'); CloseKey; end; finally Reg.Free; end; end; Of cource,in fact, this solution don't exactly hide drivers but actual solution will be processed as soon as possible in this site.