New
#10
So, how do I decode that value programmatically?!For example: To hide both the E (16) and F (32) drives, I would add 16 and 32 together from the table below, and enter 48.
I mean we have value 48 for (E + F) and we know it of our aspect!, how do I calculate the 48 to get the E & F volume?
Note that not just 48 that would be 49 or 47 !!! So we cannot just minus the 48-32-16=0 to find the volumes !!
Hello @hamedn53,
Welcome toTenForums
.
I amNOT
sure what you mean.
Regardless of what theDrive Letter[s]
are, there will be a SINGLE numeric value for them, as per the table in post 1 . . .
Code:Drive Letter Decimal Value Data Show all drives 0 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 Hide all drives 67108863
So, for example, if you hadDrives D + E + F
, the value would be56
.
I hope this helps.
Hey Paul, thanks for answering, but I do know that table values.
I meant that; I wrote an app that shows the all mounted volumes on the system, and I also have a tree-view which lists all mounted volumes of the system that has checkbox for each item of the tree-view object.
So, let's assume we did hide drives A+D+E with values of 1+8+16=25. I do know what 25 means by that table, but my app does not know how to handle that. I cannot write all the possibilities of that calculation, so I need an arithmetic algorithms to handle 25 into A,D,E volumes and so on. Am I pointed my opinion clearly?
Hello @hamedn53,
I knowNOTHING
about writingApps
, but can't you use anArray
for the values, each being designated a specific number for EACHDrive Letter
, like the Table, OR, set a Variable for EACH of the values?
Because of what you are trying to achieve, you might be better off starting your own Thread for this, and just add the link to Post 1 in this Thread so that other members can see what you are referring to.
Long time since I did this but in one way is to use bit wise boolean logic.
Trick is to convert integer into a binary string somehow.
I am only suggesting the generic logic that might work NOT any specific algorithms, program or syntax
Hope this gives you ideas.
----------------------------------------------------------------------------------------------------
Following is from Python, other languages can probably do similar.Converting int to Binary
To reveal the bits making up an integer number in Python, you can print a formatted string literal, which optionally lets you specify the number of leading zeros to display:
>>>>>> print(f"{42:b}") # Print 42 in binary
101010
>>> print(f"{42:032b}") # Print 42 in binary on 32 zero-padded digits
00000000000000000000000000101010
rather than printing, you would create a text string somehow
perhaps something like Num$= f"{42:026b}"
Then you process text string.
You would have array say L for letter
L(1)=Z
L(2)=Y
...
L(26)=A
Then you need a simple loop from 1 to 26 to look at each character in string in turn, and if 1 do actions, if 0 do nothing
something like
for i = 1 to 26
if mid$(Num$, i, 1) = 1 then
Letter = L(i)
Do actions for variable Letter
else
endif
next i
Hmm...
Has anyone devised a simple utility to hide and show specified drives?
Here's another way:
How to hide an entire drive from prying eyes on Windows 10 | Windows Central
Binary math using bitwise operators, makes this problem relatively simple.
D, E, F are the 4th, 5th & 6th letters in the range of A to Z. They each have an ordinal (index) position relative to A.
D minus A = 3 -> 2^3 = 8
E minus A = 4 -> 2^4 = 16
F minus A = 5 -> 2^5 = 32
The binary shift-left operator allows us to express 2^N by shifting the number 1 (same in binary & decimal) N positions to the left. Therefore if we take the bitwise OR operation of each of the letter's ordinal positions relative to A, we get the correct decimal value.
Code:(1 -shl 3) -bor (1 -shl 4) -bor (1 -shl 5) = 56
To decode the bitmask in the other direction, you could treat it as a 26-bit array and perform a bitwise AND operation to compare each of the possible shifted values.
With the ordinal position of the enabled bits, we can use that same position's offset from A (ASCII 65) to return a new letter.
- - - Updated - - -Code:for ($i = 1; $i -le 26; $i++) { if (( 56 -band (1 -shl $i) ) -gt 0) { [char](65 + $i) } } D E F
If you hate math, here's a PowerShell GUI for you.
The script re-loads the current NoDrives value and marks which drives are already hidden. Checking the Volumes box will alternate between clearing all selections, or selecting all drives. Don't forget to logout to force Windows to update the Explorer views.
The script will self-elevate if you're not running as Administrator. Yes, the flashing CMD windows are annoying but it all works in one script.
NoDrives.bat