It is currently May 9th, 2024, 4:14 pm

Check if a Drive Exists

Get help with creating, editing & fixing problems with skins
ilithis
Posts: 3
Joined: September 26th, 2012, 8:00 pm

Check if a Drive Exists

Post by ilithis »

Hey everyone,

I'm trying to figure out how best to approach this idea:

I want to display the drive's label, how much space is used, total space and probably other data. Now most everyone has a C:\ drive and its easy to show the information since its always there. Something like this:

C: (Label) xGB/yGB other data

I want to be able to plug in a flash drive, and for argument's sake, say Windows assigns the drive letter A:\ to it. I want the skin to update and reflect the changes of the system:

A: (School Drive) aGB/bGB other data
C: (Windows Drive) xGB/yGB other data

I was wondering if anyone knows how to check if a drive exists. I want to be able to plug in a USB drive and have the skin be able to detect the amount of space used on the flash drive as well as other drives in the system. Then, when the flash drive is removed, it would be cool to see the skin update back to:

C: (Windows Drive) xGB/yGB

Thanks,

Ilithis
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Check if a Drive Exists

Post by Kaelri »

As you probably know, the FreeDiskSpace measure provides drive information. The Type option can be used to check whether the drive exists. And since the "type" is provided as a number, you can use IfActions to make changes based on whether the drive exists or not. For example, you could have a group of meters "show" when the drive is added, and "hide" when it is removed.

Code: Select all

[MeasureDriveAExists]
Measure=FreeDiskSpace
IgnoreRemovable=0
Drive=A:
Type=1
IfAboveValue=1
IfAboveAction=!ShowMeterGroup DriveAMeters
IfBelowValue=2
IfBelowAction=!HideMeterGroup DriveAMeters
The only limitation of this is that the measure is always tied to a specific drive letter. So if your flash drive isn't always "A:" (or whatever letter), this will be trickier, though not impossible.
ilithis
Posts: 3
Joined: September 26th, 2012, 8:00 pm

Re: Check if a Drive Exists

Post by ilithis »

Thanks for the reply, I had no idea the IfActions existed and that helps solve making things appear and disappear.

I was wondering since things will be changing on the fly, is there any way to make the position of a string meter vary?

I want to use evenly spaced strings for each drive, so something like this:

X=20*#DrivesConnected#;where DrivesConnected holds 0 initially
;then update the variable with how many drives are connected to the computer
#DrivesConnected#++

I tried doing math like the above and it didn't work, I'm wondering if there is some other way to achieve making string meters' positions vary.