Pages

Wednesday, 19 October 2011

QTP Script: Get information about one of your disk drives


Dim intSectorsintBytesintFreeCintTotalCintTotal ,intFreeb

' include this windows api
extern.Declare micLong"GetDiskFreeSpace""kernel32.dll""GetDiskFreeSpaceA"micString+micByrefmicLong+micByrefmicLong+micByref,micLong+micByref,micLong+micByref

' set these values
intSectors = 255
intBytes = 255
intFreeC = 255
intTotalC = 255

' calculate the disk space, using C: in this example
intSpaceAvailable = extern.GetDiskFreeSpace("c:\"intSectorsintBytesintFreeCintTotalC)

' calculate the totals
intTotal = intTotalC * intSectors * intBytes
intFreeb = intFreeC * intSectors * intBytes

' show the outputs
msgBox intSectors
msgBox intBytes
msgBox intFreeC
msgBox intTotalC
msgbox intTotal
msgBox intFreeb


1 comments: