|
-
August 26th, 2002, 12:30 AM
#1
hard disk Space
Can anyone pls tell me how to find out all the hard disk installed in the PC
( c:, d: , e
and how to find their sizess....
Pls Help me out
thank u
-
August 26th, 2002, 03:06 AM
#2
Look at the Scripting.FileSystemObject object. Specifically, the Drives collection thereof.
- Shawn
MCP, VB6: Desktop Apps
[ C# | VB | .NET | Java | VC++ | Perl | PHP | Javascript ]
Unless otherwise stated, all sample code provided is UNTESTED.
http://www.codemastershawn.com
-
August 26th, 2002, 03:47 AM
#3
I guess Scripting.FileSystemObject may solve your problem, additionally you may have depecdency of Microsoft Scripting runtime.
This can be avioded by using API
GetLogicalDrives
The above API involves quite a bit coding as you need to resolve the drives by your self. If you are not very particular about the dependency issue, you may use Scripting.FileSystemObject as suggested by the other gentleman, ShawnDev.
Hope this helps.
-kiran.
-
August 26th, 2002, 06:05 AM
#4
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
lblDiskSpace = With oFSO.Drives(lstDrives).AvailableSpace / 1024 & " K"
-
August 26th, 2002, 07:11 AM
#5
how to know all the drives in the system...
-
August 26th, 2002, 09:22 AM
#6
Code:
Dim fso As New FileSystemObject
Dim objDrive As Drive
For Each objDrive In fso.Drives
MsgBox objDrive.DriveLetter
Next
JeffB
-
August 28th, 2002, 04:00 AM
#7
hi JeffB
when i write the above code and run it say filesystemobject not declared
in help MSDN it is using as scription language
what should i Do
Pls help me
Thank U
-
August 28th, 2002, 04:22 AM
#8
hi JeffB
when i write the above code and run it say filesystemobject not declared
in help MSDN it is using as scription language
what should i Do
Pls help me
Thank U
-
August 28th, 2002, 04:38 AM
#9
Make sure that you have referenced Microsoft Scripting Runtime
under project / references option.
-
August 28th, 2002, 05:44 AM
#10
You can use this api to get many information about yuor disks:
<From allapi guide>
1) Declare Function GetLogicalDrives Lib "kernel32" Alias "GetLogicalDrives" () As Long
If the function succeeds, the return value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.
2) Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
The return value specifies the type of drive. It can be one of the following values:
DRIVE_UNKNOWN
The drive type cannot be determined.
DRIVE_NO_ROOT_DIR
The root directory does not exist.
DRIVE_REMOVABLE
The disk can be removed from the drive.
DRIVE_FIXED
The disk cannot be removed from the drive.
DRIVE_REMOTE
The drive is a remote (network) drive.
DRIVE_CDROM
The drive is a CD-ROM drive.
DRIVE_RAMDISK
The drive is a RAM disk.
3)Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
· lpRootPathName
Points to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory.
· lpSectorsPerCluster
Points to a variable for the number of sectors per cluster.
· lpBytesPerSector
Points to a variable for the number of bytes per sector.
· lpNumberOfFreeClusters
Points to a variable for the total number of free clusters on the disk.
· lpTotalNumberOfClusters
Points to a variable for the total number of clusters on the disk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|