Adele Posted August 31, 2020 Share Posted August 31, 2020 (edited) Hello, i want to hide drives on Windows Explorer by using a registry trick https://www.tenforums.com/tutorials/79149-hide-specific-drives-windows.html. The values for each drive A:\ 1 (Index 0) B:\ 2 (Index 1) C:\ 4 (Index 2) D:\ 8 (Index 3) ....................... multiples by index. If i want to hide B:\ and D:\ drives I use BitOR(2,8)=10 or 2+8=10 and write this value to registry. I've prepared this code to show the logic. $value = 0 For $i=1 To $count If $aCheckedDrives[$i]=True Then $value+= 2^$i EndIf RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoDrives", "REG_DWORD", $value) The problem is, i want to read the value written before in registry and list all the drives hidden. I know reg functions and other things but the point i stucked is math and bit operations to list them. I can square root but the value is sum we don't know how much value there are. It may 16+128 or 256+1024+8192 etc. For example, i got 96 value from registry, how can i get indexes of drives again? I can do rest of it. Thank you! Edited August 31, 2020 by Adele Link to comment Share on other sites More sharing options...
TheXman Posted August 31, 2020 Share Posted August 31, 2020 (edited) Here's a very simple example: #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> example() Func example() Local $iDrives = 10 ; 1010 (binary) ; DCBA ; │ │ ; │ └>2^0 ; └>2^3 If BitAND($iDrives, 2^0) Then ConsoleWrite("Drive A:" & @CRLF) ;1 in decimal If BitAND($iDrives, 2^1) Then ConsoleWrite("Drive B:" & @CRLF) ;2 in decimal If BitAND($iDrives, 2^2) Then ConsoleWrite("Drive C:" & @CRLF) ;4 in decimal If BitAND($iDrives, 2^3) Then ConsoleWrite("Drive D:" & @CRLF) ;8 in decimal EndFunc Output: Drive B: Drive D: Or #include <Constants.au3> #include <Array.au3> Const $DRIVE_ARRAY = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", $STR_NOCOUNT) ; ZY XWVU TSRQ PONM LKJI HGFE DCBA _ArrayDisplay(get_drives(10), "Drives = 10") ;00 0000 0000 0000 0000 0000 1010 (BD) _ArrayDisplay(get_drives(96), "Drives = 96") ;00 0000 0000 0000 0000 0110 0000 (FG) _ArrayDisplay(get_drives(252), "Drives = 252") ;00 0000 0000 0000 0000 1111 1100 (CDEFGH) _ArrayDisplay(get_drives(33554432), "Drives = 33554432") ;10 0000 0000 0000 0000 0000 0000 (Z) Func get_drives($iDrives) #cs Binary bits ZYXWVUTSRQPONMLKJIHGFEDCBA │ │ └>2^25 └>2^0 #ce Local $aDrives[0] ;Identify each bit that is set (0 - 25) For $i = 0 To 25 If BitAND($iDrives, 2 ^ $i) Then _ArrayAdd($aDrives, $DRIVE_ARRAY[$i]) Next Return $aDrives EndFunc Edited September 1, 2020 by TheXman Corrected binary representation decimal 10 =1010b Adele 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Adele Posted August 31, 2020 Author Share Posted August 31, 2020 Works, thank you! Link to comment Share on other sites More sharing options...
TheXman Posted August 31, 2020 Share Posted August 31, 2020 You're welcome! CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Adele Posted September 1, 2020 Author Share Posted September 1, 2020 (edited) Fixed. Edited September 1, 2020 by Adele Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now