Determining disk drive information

VBA doesn't have a way to directly get information about disk drives. But with the assistance of three API functions, you can get just about all of the information you need.

Figure 11-19 shows the output from a VBA procedure that identifies all connected drives, determines the drive type, and calculates total space, used space, and free space. In the example shown, the system has six drives connected.

Q

« 1

1

1

U

^^^^Blfrivr H 1 hu- niÛUjB^Tl-. BLIW^UTII-^ Blin-Ul^l".

1 a

c\

mid QHBH

mmMtiOii

TI.HLMa.îW

7ÎJOIS.MJ.OÎ!

9

E:\

tMM

127,MÏ7.B40

RMd

HUWMI

Hj.wftjîs.ujï

1IUM9W

ai

riLMl

nr.m.aj.ta

! nfi.1,!:,[iL,inn.

ILH3T, an, AM

U

• tKt'MK

lM.M4.iM.

»¿H.M

L174MJJM

LI

(R.1UW!

Uf.lP5.lK,IB!,

U

h 1

' > nwi

Figure 11-19: Using Windows API functions to get disk drive information.

Figure 11-19: Using Windows API functions to get disk drive information.

The code is rather lengthy, so I don't list it here, but the interested reader should be able to figure it out by examining the code on the CD-ROM.

CD- This example is available on the companion CD-ROM in a file named % drive ROM information.xlsm.

0 0

Post a comment