Hide Drives and Partitions

Hide Drives and Partitions

Postby Silvio » Mon Aug 28, 2006 6:00 pm

I must change the Registry at :
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\explorer

at the option NoDrives
and set wich drive I want hide but on the microsoft manual I saw these parameters :

----------------------------------------------------------------------
The values for each drive are as follows:

1 - A I Q Y
2 - B J R Z
4 - C K S
8 - D L T
16 - E M U
32 - F N V
64 - G O W
80 - H P X

So, let's say you want to hide drive D. In the first column you would put "08". For drive K you would put "04" in the second column.
But what if you want to hide more than one drive in a column? Simply add the values together: D+E = 8+16 = 24. So in the first column you would put "24".

---------------------------------------------------------------

But I KNOW How set this variable in a program with xharbour and fivewin

there is someone can help me ?

Best Regards
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Detlef Hoefner » Mon Aug 28, 2006 7:33 pm

Hi Silvio,

this remembers me to riddle inside of Monkey Island :wink:

Maybe the following could help you.
Code: Select all  Expand view
The NoDrives value can be used to selectively hide drives because the rightmost bit of this hexadecimal value represents the A: drive, and the leftmost bit represents the Z: drive. To hide a specific drive, turn on its bit. Use the following decimal numbers to hide the given drive:

A: 1, B: 2, C: 4, D: 8, E: 16, F: 32, G: 64, H: 128, I: 256, J: 512, K: 1024, L: 2048, M: 4096, N: 8192, O: 16384, P: 32768, Q: 65536, R: 131072, S: 262144, T: 524288, U: 1048576, V: 2097152, W: 4194304, X: 8388608, Y: 16777216, Z: 33554432, ALL: 67108863.

Best regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Silvio » Tue Aug 29, 2006 8:25 am

ok but using the Treg class How I must make to hide hard disk and then show it ?
I'm afraid to make a bad work making errors with treg class and then my pc not run well
Can you hel me pls
Regards
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Detlef Hoefner » Tue Aug 29, 2006 9:32 am

Silvio,

the only problem is how to create a 26-bit binary string.
You may google yourself or have a look at http://support.microsoft.com/default.aspx?scid=kb;en-us;231289

Here an extract :

Code: Select all  Expand view
This policy displays only specified drives on the client computer. The registry key that this policy affects uses a decimal number that corresponds to a 26-bit binary string, with each bit representing a drive letter:

11111111111111111111111111
ZYXWVUTSRQPONMLKJIHGFEDCBA
            
This configuration corresponds to 67108863 in decimal and hides all drives. If you want to hide drive C, make the third-lowest bit a 1, and then convert the binary string to decimal.

It is not necessary to create an option to show all drives, because clearing the check box deletes the "NoDrives" entry entirely, and all drives are automatically shown.

If you want to configure this policy to show a different combination of drives, create the appropriate binary string, convert to decimal, and add a new entry to the ITEMLIST section with a corresponding [strings] entry. For example, to hide drives L, M, N, and O, create the following string

00000000000111100000000000
ZYXWVUTSRQPONMLKJIHGFEDCBA
            
and convert to decimal. This binary string converts to 30720 in decimal. Add this line to the [strings] section in the System.adm file: LMNO_Only="Restrict L, M, N and O drives only"


Or you could try a tool like Tweak XP to see how the reg key is changed when hiding certain drives.

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Detlef Hoefner » Tue Aug 29, 2006 2:36 pm

Silvio,

please stop writing to my private mailaddress.
It's better that more people than only you may benefit from this forum.

So here is what you asked me for. IMO, you could have googled this yourself.

HKEY_CLASSES_ROOT = 2147483648
HKEY_CURRENT_USER = 2147483649
HKEY_LOCAL_MACHINE = 2147483650
HKEY_USERS = 2147483651
HKEY_CURRENT_CONFIG = 2147483653
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Silvio » Tue Aug 29, 2006 3:07 pm

>It's better that more people than only you may benefit from this forum. ...

you're right but there are many people help me never if you go at this forum there are many many my messages of which I have not had answer....
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Silvio » Tue Aug 29, 2006 3:11 pm

for hard disk i saw i must insert this :

4294967291 for drive C
4294967293 for drive D
4294967294 for drive A

but when I insert it I can see these drives : why ?

Infact I open regedit and insert 4294967291 for drive C on nodrives
and the I make this program :

Code: Select all  Expand view

// Managing Register services from FiveWin

#ifndef __XPP__
   #define  HKEY_CLASSES_ROOT       2147483648
   #define  HKEY_CURRENT_USER       2147483649
   #define  HKEY_LOCAL_MACHINE      2147483650
   #define  HKEY_USERS              2147483651
   #define  HKEY_PERFORMANCE_DATA   2147483652
   #define  HKEY_CURRENT_CONFIG     2147483653
   #define  HKEY_DYN_DATA           2147483654
#else
   #define  HKEY_CLASSES_ROOT       1
   #define  HKEY_CURRENT_USER       2
   #define  HKEY_LOCAL_MACHINE      3
   #define  HKEY_USERS              4
   #define  HKEY_PERFORMANCE_DATA   5
   #define  HKEY_CURRENT_CONFIG     6
   #define  HKEY_DYN_DATA           7
#endif

//---------------------------------------------------------------------------//

function Main()

   local nHandle, cValue

   if RegOpenKey( HKEY_CURRENT_USER ,;
         "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", @nHandle ) == 0

      RegQueryValue( nHandle, "NoDrives", @cValue )
      MsgInfo( cValue )
      RegCloseKey( nHandle )
   else
      MsgAlert( "Can't open this key" )
   endif

return nil


but it return me a symbol ...why ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Detlef Hoefner » Tue Aug 29, 2006 4:00 pm

Silvio,

for hard disk i saw i must insert this :

4294967291 for drive C
4294967293 for drive D
4294967294 for drive A



how did you get these values?

here again:
Code: Select all  Expand view
how to hide drive 'C' ( which is very foolish )

ZYXWVUTSRQPONMLKJIHGFEDCBA ( all drive letters )
00000000000000000000000100 ( binary settings )
you'll have to put '4'     ( decimal value of above binary )


Better for testing try to hide drive 'D'

ZYXWVUTSRQPONMLKJIHGFEDCBA ( all drive letters )
00000000000000000000001000 ( binary setting )
you'll have to put '8'     ( decimal value of above binary )

And here an example for hiding drives 'E' and 'D'

ZYXWVUTSRQPONMLKJIHGFEDCBA ( all drive letters )
00000000000000000000001100 ( binary setting )
you'll have to put '12'    ( decimal value of above binary )

So you see how it's easy:
you write down all possible drive letters from A to Z beginning with 'Z'.
Then you replace all drive letters you want to see with a '0' and replace all letters you want to hide with a '1'.
After replacing all letters with the numeric equivalent you got a string representing a binary number. This you'll have to convert to a decimal number and write this value into your reg-key.

BTW, i found it very unpleasant if you complain about missing help from this forum.

I saw a lot of people which were busy during the last weeks by answering your questions.
Remember, no one is obliged to help, but a lot of FiveWinners do.
Even if they are busy with their jobs.

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Silvio » Tue Aug 29, 2006 5:13 pm

Sorry YOu are right for all

but...but... but..
I not understand and I not Know how I can make it translating in code ( harbour/fw)...
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby AlexSchaft » Wed Aug 30, 2006 4:24 am

To convert numbers, you can use the following functions:

Code: Select all  Expand view
Function Dec2x(pnNo, pnBase)

  Local cRetVal              := ""
  Local nCount               := 0
  Local acDigits             := {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
  Local nNo                  := 0

  For nCount := 65 to 65 + pnBase - 11
    aadd(acDigits, chr(nCount))
  Next

  For nCount := 7 to 0 step - 1
    nNo                      := int(pnNo / (pnBase**nCount))
    If nNo > 0 .or. !empty(cRetVal)
      cRetVal                += acDigits[nNo + 1]

      pnNo                   -= nNo * pnBase**nCount
    Endif
  Next

Return cRetval

//------------------------------------------------------------------------------------------------------//
Function x2dec(pcNo, pnBase, plNoWarningMsg)

  Local nRetVal              := 0
  Local nPos                 := 0
  Local acDigits             := {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
  Local nCount               := 0
  Local nStop                := 0
  Local cDigit               := ""

  DEFAULT plNoWarningMsg     TO .t.

  For nCount := 65 to 65 + pnBase - 11
    aadd(acDigits, chr(nCount))
  Next

  nStop                      := len(pcNo)
  For nCount := 1 to nStop
    cDigit                   := substr(pcNo, nStop - nCount + 1, 1)

    nPos                     := ascan(acDigits, cDigit)

    If nPos > 0
      nRetval                += (nPos - 1) * (pnBase ** (nCount - 1))

    Elseif !plNoWarningMsg
      // pk 20/9/2002 msginfo("Invalid number " + pcNo + " " + alias() + " " + NTRIM(recno()))
      msginfo("Warning - function x2dec(), invalid parameter value " + pcNo, "Warning")

    Endif

  Next

  nRetval                    := int(nRetval)

Return nRetval


And for the registry part

Code: Select all  Expand view

#define HKEY_CURRENT_USER   -2147483647  // 2147483649

oReg := TReg32():New(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\explorer")

oReg:Set("NoDrives", ltrim(str((nNumber)))

oReg:End()



Not sure how to set the entry type though
User avatar
AlexSchaft
 
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Postby Detlef Hoefner » Wed Aug 30, 2006 7:01 am

Silvio,

here a small function for getting the numeric value for hiding drives.

Code: Select all  Expand view
PROCEDURE Main()
   cls

   ? nDriveNum( "EDA" ) // getting number to hide drives E, D and A
   ?
RETURN

/////////////////////////////
FUNCTION nDriveNum( cDrives )
/////////////////////////////
LOCAL nRet := 0
LOCAL n    := 0



   for n := 1 to len( cDrives )
      nRet += 2 ^( asc( upper( substr( cDrives, n, 1 ) ) ) - 65 )
   next

RETURN( int( nRet ) )


You just have to call this function with a string containing the drive letter(s) you want to hide.

HTH,
regards,
Detlef

P.S. my recent example for hiding drives 'E' and 'D' was wrong.
The value should have been 24.
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Silvio » Wed Aug 30, 2006 8:20 am

thanks for all
I will make treasure of your instructions ...


Dear alex thanks

Dear Detlef Hoefner,
you sad to put "4" on variable Nodrives ..
I open regedit and insert 4 on nodrives the f5 to update
then I saw it not run because I can see hard disk C
Is it possible that number 4 is wrong ?.
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Silvio » Wed Aug 30, 2006 8:37 am

look this and try ( i havewin xp professional :
Code: Select all  Expand view
#INCLUDE "fivewin.ch"

  #define HKEY_CURRENT_USER   -2147483647  // 2147483649

PROCEDURE Main()
   cls

   ? nDriveNum( "C" ) // getting number to hide drives E, D and A
   ?
   registra(nDriveNum( "C" ))
RETURN

/////////////////////////////
FUNCTION nDriveNum( cDrives )
/////////////////////////////
LOCAL nRet := 0
LOCAL n    := 0



   for n := 1 to len( cDrives )
      nRet += 2 ^( asc( upper( substr( cDrives, n, 1 ) ) ) - 65 )
   next

   RETURN( int( nRet ) )
FUNCTION registra(nNumber)


oReg := TReg32():New(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\explorer")

oReg:Set("NoDrives", nNumber)

oReg:Close()

RETURN nil


it insert number 4 on regedit but when I open explorer I can see hard disk C why ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby AlexSchaft » Wed Aug 30, 2006 8:55 am

According to one web site, you need to restart windows

Google is your friend :)

http://www.winguides.com/registry/display.php/148/
User avatar
AlexSchaft
 
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Postby Silvio » Wed Aug 30, 2006 10:22 am

I cannot restart windows
there is a possibility to restart using an function ?
If I restart the program ?
it must be made without restart window ...then If I want to show disc C I must restart window...
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 71 guests